Share via


LogSection Class [IIS 7 and higher]

Configures the logging for a server or site.

Syntax

class LogSection : ConfigurationSection

Methods

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

Name

Description

GetAllowDefinition

(Inherited from ConfigurationSection.)

GetAllowLocation

(Inherited from ConfigurationSection.)

RevertToParent

(Inherited from ConfigurationSection.)

SetAllowDefinition

(Inherited from ConfigurationSection.)

SetAllowLocation

(Inherited from ConfigurationSection.)

Properties

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

Name

Description

CentralBinaryLogFile

A read/write CentralBinaryLogFile value that specifies the configuration of centralized binary logging for all sites on a server.

CentralLogFileMode

A read/write sint32 value that specifies the centralized logging mode for the server. The possible values are listed later in the Remarks section.

CentralW3CLogFile

A read/write CentralW3CLogFile value that specifies the configuration of World Wide Web Consortium (W3C) centralized logging for all sites on a server.

Location

(Inherited from ConfigurationSection.) A key property.

LogInUTF8

A read/write boolean value. true if IIS logs all strings in UCS Transformation Format 8 (UTF-8); otherwise, false. The default is true. This setting applies serverwide to all text-mode logging.

Path

(Inherited from ConfigurationSection.) A key property.

SectionInformation

(Inherited from ConfigurationSection.)

Subclasses

This class contains no subclasses.

Remarks

This class corresponds to the <system.applicationHost/log> section in ApplicationHost.config.

The following table lists the possible values for the CentralLogFileMode property. The default is 0 (Site).

Value

Keyword

Description

0

Site

All client requests are logged at the site level, not centrally at the server level. Log files are generated per site.

1

CentralBinary

All client requests for all sites are logged to a single log file in centralized binary format on the server.

2

CentralW3C

All client requests for all sites are logged to a single log file in W3C centralized format on the server.

Example

The following code example displays the value of the CentralLogFileMode property. A helper function translates the enumeration value to text.

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

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

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

' Display the path and location.
WScript.Echo "Path: " & oSection.Path
WScript.Echo "Location: " & oSection.Location

' Display the central log file mode.
WScript.Echo "CentralLogFileMode: " & _
                GetModeText(oSection.CentralLogFileMode)

' ==== GetModeText helper function. ====
Function GetModeText(intMode)
    Select Case intMode
        Case 0
            GetModeText="Site"
        Case 1
            GetModeText="CentralBinary"
        Case 2
            GetModeText="CentralW3C"
        Case Else
            GetModeText="Undefined value"
    End Select
End Function

Inheritance Hierarchy

ConfigurationSection

   LogSection

Requirements

Type

Description

Client

Requires IIS 7 on Windows Vista.

Server

Requires IIS 7 on Windows Server 2008.

Product

IIS 7

MOF file

WebAdministration.mof

See Also

Reference

ConfigurationSection Class [IIS 7 and higher]

CentralBinaryLogFile Class [IIS 7 and higher]

CentralW3CLogFile Class [IIS 7 and higher]

SiteLogFile Class [IIS 7 and higher]