CentralW3CLogFile 类 1

为服务器上的万维网联盟 (W3C) 集中式日志记录配置设置。

语法

class CentralW3CLogFile : EmbeddedObject  

方法

此类不包含任何方法。

属性

下表列出了 CentralW3CLogFile 类公开的属性。

名称 描述
Directory 一个非空读/写 string 值,用于指定日志条目应写入的目录。 默认为“%SystemDrive%\inetpub\logs\LogFiles”。
Enabled 一个读/写 boolean 值。 启用了 W3C 集中式日志记录时,为 true,否则为 false。 默认为 true
LocalTimeRollover 一个读/写 boolean 值。 新的日志文件基于当地时间时,为 true;基于协调世界时 (UTC) 时,则为 false。 默认为 false
LogExtFileFlags 一个读/写 sint32 值,该值包含一个掩码,指定要在日志文件中记录的属性。 后文的“备注”部分列出了可能的值。
Period 一个读/写 sint32 枚举,该值指定当前日志文件关闭的频率以及启动新日志文件的频率。 后文的“备注”部分列出了可能的值。
TruncateSize 一个读/写 string 值,该值指定日志文件内容应截断的大小(以字节为单位)。 当 Period 设置为 MaxSize 时,必须配置此属性。 大小须介于 1048576 (1 MB) 和 4294967295 (4 GB) 之间。 默认为 20971520 (20 MB)。

子类

此类不包含子类。

注解

此类的实例包含在 LogSection 类的 CentralW3CLogFile 属性中。

下表列出了 LogExtFileFlags 属性可能的值。 默认属性为 ClientIPDateHttpStatusHttpSubStatusMethodServerIPServerPortSiteNameTimeUriQueryUriStemUserAgentUserNameWin32Status

属性
1 Date
2 Time
4 ClientIP
8 UserName
16 SiteName
32 ComputerName
64 ServerIP
128 Method
256 UriStem
512 UriQuery
1024 HttpStatus
2048 Win32Status
4096 BytesSent
8192 BytesRecv
16384 TimeTaken
32768 ServerPort
65536 UserAgent
131072 Cookie
262144 Referer
524288 ProtocolVersion
1048576 Host
2097152 HttpSubStatus

下表列出了 Period 属性可能的值。 默认值为 1 (Daily)。

关键字 说明
0 MaxSize 达到 TruncateSize 中的值时,关闭日志文件并启动新的日志文件。
1 Daily 每天关闭日志文件并启动新的日志文件。
2 Weekly 每周关闭日志文件并启动新的日志文件。
3 Monthly 每月关闭日志文件并启动新的日志文件。
4 Hourly 每小时关闭日志文件并启动新的日志文件。

示例

以下代码示例将日志文件模式设置为 CentralW3C,启用 centralW3C 日志记录,将 Period 属性设置为 MaxSize,指定日志文件使用当地时间,并将日志大小限制为 100 MB。 帮助程序函数显示更改前后的设置。

' 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 CentralW3C.  
oSection.CentralLogFileMode = 2  
  
' Enable central W3C logging.  
oSection.CentralW3CLogFile.Enabled = True  
  
' Set local time rollover to true.  
oSection.CentralW3CLogFile.LocalTimeRollover = True  
  
' Set the Period property to MaxSize.  
oSection.CentralW3CLogFile.Period = 0  
  
' Set the log truncate size to 100 megabytes.  
oSection.CentralW3CLogFile.TruncateSize = 104857600  
  
' 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 W3C log file properties.  
   Call ShowPropVals(oSection.CentralW3CLogFile)  
  
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  
  

继承层次结构

EmbeddedObject

CentralW3CLogFile

要求

类型 描述
客户端 - IIS 7.0(在 Windows Vista 上)
- IIS 7.5(在 Windows 7 上)
- IIS 8.0(在 Windows 8 上)
- IIS 10.0(在 Windows 10 上)
服务器 - IIS 7.0(在 Windows Server 2008 上)
- IIS 7.5(在 Windows Server 2008 R2 上)
- IIS 8.0(在 Windows Server 2012 上)
- IIS 8.5(在 Windows Server 2012 R2 上)
- IIS 10.0(在 Windows Server 2016 上)
产品 - IIS 7.0、IIS 7.5、IIS 8.0、IIS 8.5、IIS 10.0
MOF 文件 WebAdministration.mof

另请参阅

CentralBinaryLogFile 类
EmbeddedObject 类
LogSection 类
SiteLogFile 类