設定 HTTP 要求的記錄。
Syntax
class HttpLoggingSection : ConfigurationSection
方法
下表列出 類別所 HttpLoggingSection 公開的方法。
| 名稱 | 描述 |
|---|---|
| GetAllowDefinition | (繼承自 ConfigurationSection.) |
| GetAllowLocation | (繼承自 ConfigurationSection。) |
| RevertToParent | (繼承自 ConfigurationSection。) |
| SetAllowDefinition | (繼承自 ConfigurationSection。) |
| SetAllowLocation | (繼承自 ConfigurationSection。) |
屬性
下表列出 類別所 HttpLoggingSection 公開的屬性。
| 名稱 | 描述 |
|---|---|
DontLog |
讀取/寫入 boolean 值。 true 如果成功要求已停用記錄,則為 ; false 如果記錄成功的要求,則為 。 如果要求的狀態碼小於 400,則會被視為成功。 預設值為 false。 注意: 這個屬性與 IIS 6.0 中的 DontLog Metabase 屬性相同。 |
Location |
(繼承自 ConfigurationSection .) 金鑰屬性。 |
Path |
(繼承自 ConfigurationSection .) 金鑰屬性。 |
SectionInformation |
(繼承自 ConfigurationSection。) |
SelectiveLogging |
sint32列舉,指定要記錄的事件。 後續的一節會列出可能的值。 |
子類別
這個類別不包含子類別。
備註
這個類別會對應至 <system.webServer/httpLogging> ApplicationHost.config檔案中的 區段。
下表列出 屬性的 SelectiveLogging 可能值。 預設值為 0 (LogAll) 。
| 值 | 關鍵字 | 描述 |
|---|---|---|
| 0 | LogAll |
系統會記錄所有要求。 |
| 1 | LogSuccessful |
只會記錄成功的要求。 如果要求的狀態碼小於 400,則會被視為成功。 |
| 2 | LogError |
只會記錄失敗的要求。 如果要求的狀態碼大於或等於 400,則會被視為失敗。 |
範例
下列程式碼範例會將 SelectiveLogging 屬性設定為 LogError 。
' Connect to the WMI WebAdministration namespace.
Set oWebAdmin = GetObject( _
"winmgmts:root\WebAdministration")
' Get the HTTP logging section.
Set oSection = oWebAdmin.Get( _
"HttpLoggingSection.Path=" & _
"'MACHINE/WEBROOT/APPHOST',Location=''")
' Display the class name of the section.
WScript.Echo "[ " & oSection.Path_.Class & " ]" & vbCrLf
' Display the initial settings.
Call DisplaySettings("Initial Values", oSection)
' Set the SelectiveLogging property to LogError.
oSection.SelectiveLogging = 2
' Save new values to configuration.
oSection.Put_
' Refresh the oSection object variable with new values.
oSection.Refresh_
' Show changed settings.
Call DisplaySettings("New Values", oSection)
' ==== DisplaySettings helper function. ====
Function DisplaySettings(HeadingText, oSection)
' Display a heading.
WScript.Echo String(Len(HeadingText), "-")
WScript.Echo HeadingText
WScript.Echo String(Len(HeadingText), "-")
' Display configuration history section properties.
WScript.Echo "Path: " & oSection.Path
WScript.Echo "Location: " & oSection.Location
WScript.Echo "DontLog: " & oSection.DontLog
WScript.Echo "SelectiveLogging: " & _
oSection.SelectiveLogging
WScript.Echo
End Function
繼承階層架構
HttpLoggingSection
規格需求
| 類型 | 描述 |
|---|---|
| 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 類別
CentralW3CLogFile 類別
ConfigurationSection 類別
OdbcLoggingSection 類別
LogSection 類別
SiteLogFile 類別
DontLog Metabase 屬性 (IIS 6.0)