設定萬維網聯盟 (W3C) 集中記錄伺服器上的設定。
Syntax
class CentralW3CLogFile : EmbeddedObject
方法
這個類別不包含任何方法。
屬性
下表列出 類別所 CentralW3CLogFile 公開的屬性。
| 名稱 | 描述 |
|---|---|
Directory |
無空讀取/寫入 string 值,指定應該寫入記錄專案的目錄。 預設值為 「%SystemDrive%\inetpub\logs\LogFiles」。 |
Enabled |
讀取/寫入 boolean 值。 true 如果已啟用 W3C 集中式記錄,則為 ;否則為 false 。 預設值為 true。 |
LocalTimeRollover |
讀取/寫入 boolean 值。 true 如果新的記錄檔是以當地時間為基礎,則為 ; false 如果以國際標準時間 (UTC) 為基礎,則為 。 預設值為 false。 |
LogExtFileFlags |
讀取/寫入 sint32 值,其中包含遮罩,指定要記錄在記錄檔中的屬性。 後續的一節會列出可能的值。 |
Period |
讀取/寫入 sint32 列舉,指定關閉目前記錄檔的頻率,以及啟動新的記錄檔。 後續的一節會列出可能的值。 |
TruncateSize |
讀取/寫入 string 值,指定應該截斷記錄檔內容的大小,以位元組為單位。 當 設定為 MaxSize 時 Period ,必須設定這個屬性。 大小必須介於 1048576 (1 MB) 和 4294967295 (4 GB) 之間。 預設值為 20971520 (20 MB) 。 |
子類別
這個類別不包含子類別。
備註
這個類別的實例包含在 CentralW3CLogFileLogSection 類別的 屬性中。
下表列出 屬性的 LogExtFileFlags 可能值。 預設屬性為 ClientIP 、 Date 、 HttpStatus 、 HttpSubStatusMethod 、 ServerIP 、 ServerPort 、、 UriQuerySiteNameUriStemUserAgentTimeUserName 、、 和 。 Win32Status
| 值 | 屬性 |
|---|---|
| 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
繼承階層架構
CentralW3CLogFile
規格需求
| 類型 | 描述 |
|---|---|
| Client | - Windows Vista 上的 IIS 7.0 - Windows 7 上的 IIS 7.5 - Windows 8 上的 IIS 8.0 - Windows 10上的 IIS 10.0 |
| 伺服器 | - Windows Server 2008 上的 IIS 7.0 - Windows Server 2008 R2 上的 IIS 7.5 - Windows Server 2012 上的 IIS 8.0 - Windows Server 2012 R2 上的 IIS 8.5 - Windows Server 2016上的 IIS 10.0 |
| 產品 | - IIS 7.0、IIS 7.5、IIS 8.0、IIS 8.5、IIS 10.0 |
| MOF 檔案 | WebAdministration.mof |
另請參閱
CentralBinaryLogFile 類別
EmbeddedObject 類別
LogSection 類別
SiteLogFile 類別