Export (0) Print
Expand All
Expand Minimize

HttpLoggingSection Class [IIS 7 and higher]

IIS 7.0

Configures the logging of HTTP requests.

class HttpLoggingSection : ConfigurationSection

The following table lists the methods exposed by the HttpLoggingSection class.

Name

Description

GetAllowDefinition

(Inherited from ConfigurationSection.)

GetAllowLocation

(Inherited from ConfigurationSection.)

RevertToParent

(Inherited from ConfigurationSection.)

SetAllowDefinition

(Inherited from ConfigurationSection.)

SetAllowLocation

(Inherited from ConfigurationSection.)

The following table lists the properties exposed by the HttpLoggingSection class.

Name

Description

DontLog

A read/write boolean value. true if logging is disabled for successful requests; false if successful requests are logged. A request is considered successful if its status code is less than 400. The default is false.

NoteNote:
This property is the same as the DontLog metabase property in IIS 6.0.

Location

(Inherited from ConfigurationSection.) A key property.

Path

(Inherited from ConfigurationSection.) A key property.

SectionInformation

(Inherited from ConfigurationSection.)

SelectiveLogging

A sint32 enumeration that specifies the events to log. The possible values are listed later in the Remarks section.

This class contains no subclasses.

This class corresponds to the <system.webServer/httpLogging> section in the ApplicationHost.config file.

The following table lists the possible values for the SelectiveLogging property. The default is 0 (LogAll).

Value

Keyword

Description

0

LogAll

All requests are logged.

1

LogSuccessful

Only successful requests are logged. A request is considered successful if its status code is less than 400.

2

LogError

Only failed requests are logged. A request is considered failed if its status code is greater than or equal to 400.

The following code example sets the SelectiveLogging property to LogError.

' Connect to the WMI WebAdministration namespace.
Set oWebAdmin = GetObject( _
    "winmgmts:root\WebAdministration")

' Get the HTTP logging section.
Set oSection = oWebAdmin.Get( _
    "HttpLoggingSection.Path=" & _
    "'MACHINE/WEBROOT/APPHOST',Location=''")

' Display the class name of the section.
WScript.Echo "[ " & oSection.Path_.Class & " ]" & vbCrLf

' Display the initial settings.
Call DisplaySettings("Initial Values", oSection)

' Set the SelectiveLogging property to LogError.
    oSection.SelectiveLogging = 2

' Save new values to configuration.
oSection.Put_

' Refresh the oSection object variable with new values.
oSection.Refresh_

' Show changed settings.
Call DisplaySettings("New Values", oSection)

' ==== DisplaySettings helper function. ====
Function DisplaySettings(HeadingText, oSection)

    ' Display a heading.
    WScript.Echo String(Len(HeadingText), "-")
    WScript.Echo HeadingText
    WScript.Echo String(Len(HeadingText), "-")

    ' Display configuration history section properties.
    WScript.Echo "Path: " & oSection.Path
    WScript.Echo "Location: " & oSection.Location
    WScript.Echo "DontLog: " & oSection.DontLog
    WScript.Echo "SelectiveLogging: " & _
        oSection.SelectiveLogging
    WScript.Echo
End Function

Type

Description

Client

Requires IIS 7 on Windows Vista.

Server

Requires IIS 7 on Windows Server 2008.

Product

IIS 7

MOF file

WebAdministration.mof

Community Additions

ADD
Show:
© 2014 Microsoft