配置 HTTP 请求的日志记录。
语法
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 元数据库属性相同。 |
Location |
(继承自 ConfigurationSection。)一个键属性。 |
Path |
(继承自 ConfigurationSection。)一个键属性。 |
SectionInformation |
(从 ConfigurationSection 继承。) |
SelectiveLogging |
一个 sint32 枚举,指定要记录的事件。 后文的“备注”部分列出了可能的值。 |
子类
此类不包含子类。
注解
此类对应于 ApplicationHost.config 文件中的 <system.webServer/httpLogging> 部分。
下表列出了 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
要求
| 类型 | 描述 |
|---|---|
| 客户端 | - 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 类
CentralW3CLogFile 类
ConfigurationSection 类
OdbcLoggingSection 类
LogSection 类
SiteLogFile 类
DontLog 元数据库属性 (IIS 6.0)