CentralBinaryLogFile Class [IIS 7 and higher]
Configures settings for centralized binary logging on a server.
The following table lists the properties exposed by the CentralBinaryLogFile class.
A read/write string value that specifies the directory to which log entries should be written. The default is "%SystemDrive%\inetpub\logs\LogFiles".
A read/write boolean value. true if centralized binary logging is enabled; otherwise, false. The default is true.
A read/write boolean value. true if a new log file is based on local time; false if it is based on Coordinated Universal Time (UTC). The default is false.
A read/write sint32 enumeration that specifies how frequently the current log file is closed and a new log file is started. The possible values are listed later in the Remarks section.
A read/write string value that specifies, in bytes, the size at which the log file contents should be truncated. This attribute must be configured when Period is set to MaxSize. The size must be between 1048576 (1 megabyte) and 4294967295 (4 gigabytes). The default is 20971520 (20 megabytes).
Instances of this class are contained in the CentralBinaryLogFile property of the LogSection class.
The following table lists the possible values for the Period property. The default is 1 (Daily).
The log file is closed and a new log file is started when the value in TruncateSize is reached.
The log file is closed and a new log file is started once per day.
The log file is closed and a new log file is started once per week.
The log file is closed and a new log file is started once per month.
The log file is closed and a new log file is started once per hour.
The following code example sets the log file mode to CentralBinary, enables binary logging, sets the Period property to Weekly, specifies that log files use local time, and limits the log size to 1 gigabyte. Helper functions display the settings before and after the changes are made.
' Connect to the WMI WebAdministration namespace. Set oWebAdmin = GetObject("winmgmts:root\WebAdministration") ' Get the log configuration section. Set oSection = oWebAdmin.Get("LogSection.Path=" & _ "'MACHINE/WEBROOT/APPHOST',Location=''") ' Show the initial settings. DisplaySettings("Initial Values") ' Set the log file mode to CentralBinary. oSection.CentralLogFileMode = 1 ' Enable central binary logging. oSection.CentralBinaryLogFile.Enabled = True ' Set local time rollover to true. oSection.CentralBinaryLogFile.LocalTimeRollover = True ' Set the Period property to Weekly. oSection.CentralBinaryLogFile.Period = 2 ' Set the log truncate size to 1 gigabyte. oSection.CentralBinaryLogFile.TruncateSize = 1073741824 ' Save the values to configuration. oSection.Put_ ' Refresh the oSection object variable with the new values. oSection.Refresh_ ' Show the changed settings. Call DisplaySettings("New Values") ' ==== This section contains helper functions. ==== Function DisplaySettings(HeadingText) WScript.Echo String(Len(HeadingText), "=") WScript.Echo HeadingText WScript.Echo String(Len(HeadingText), "=") ' Display the current central log file mode. WScript.Echo "CentralLogFileMode: " & _ oSection.CentralLogFileMode ' Display the current binary log file properties. Call ShowPropVals(oSection.CentralBinaryLogFile) End Function ' Display the property values. Function ShowPropVals(oObject) For Each Prop In oObject.Properties_ WScript.Echo Prop.Name & ": " & Prop.Value Next WScript.Echo End Function