設定伺服器上集中式二進位記錄的設定。
Syntax
class CentralBinaryLogFile : EmbeddedObject
方法
這個類別不包含方法。
屬性
下表列出 類別所 CentralBinaryLogFile 公開的屬性。
| 名稱 | 描述 |
|---|---|
Directory |
讀取/寫入 string 值,指定應該寫入記錄專案的目錄。 預設值為 「%SystemDrive%\inetpub\logs\LogFiles」。 |
Enabled |
讀取/寫入 boolean 值。 true 如果已啟用集中式二進位記錄,則為 ;否則為 false 。 預設值為 true。 |
LocalTimeRollover |
讀取/寫入 boolean 值。 true 如果新的記錄檔是以當地時間為基礎,則為 ; false 如果以國際標準時間 (UTC) 為基礎,則為 。 預設值為 false。 |
Period |
讀取/寫入 sint32 列舉,指定關閉目前記錄檔的頻率,並啟動新的記錄檔。 可能的值稍後會列在一節中。 |
TruncateSize |
讀取/寫入 string 值,指定記錄檔內容應截斷的大小,以位元組為單位。 當 設定為 MaxSize 時 Period ,必須設定這個屬性。 大小必須介於 1048576 (1 MB) 和 4294967295 (4 GB) 之間。 預設值為 20971520 (20 MB) 。 |
子類別
這個類別不包含子類別。
備註
這個類別的實例包含在LogSection類別的 屬性中 CentralBinaryLogFile 。
下表列出 屬性的可能值 Period 。 預設值為 1 (Daily) 。
| 值 | 關鍵字 | 描述 |
|---|---|---|
| 0 | MaxSize |
記錄檔已關閉,且達到 中的 TruncateSize 值時會啟動新的記錄檔。 |
| 1 | Daily |
記錄檔已關閉,而且每天會啟動一次新的記錄檔。 |
| 2 | Weekly |
記錄檔已關閉,而且每週會啟動一次新的記錄檔。 |
| 3 | Monthly |
記錄檔已關閉,而且每個月會啟動一次新的記錄檔。 |
| 4 | Hourly |
記錄檔已關閉,而且每小時會啟動一次新的記錄檔。 |
範例
下列程式碼範例會將記錄檔模式設定為 CentralBinary 、啟用二進位記錄、將 屬性 Weekly 設定 Period 為 、指定記錄檔使用當地時間,並將記錄大小限制為 1 GB。 協助程式函式會在變更前後顯示設定。
' 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
繼承階層架構
CentralBinaryLogFile
規格需求
| 類型 | 描述 |
|---|---|
| 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 |
另請參閱
CentralW3CLogFile 類別
EmbeddedObject 類別
LogSection 類別
SiteLogFile 類別