禁用特定的W3C日志logging字段

是否有命令或PS命令来禁用特定的W3C日志logging字段?

我知道你可以去IISpipe理器,并取消选中框,但我有几百个服务器来做。

这里有一个powershell命令:

Set-WebConfigurationProperty 

您可以在IIS GUI中轻松生成命令。 select服务器(IIS的顶层),然后selectconfiguration编辑器。 转到“system.applicationHost / log”部分。 进行编辑,然后find“生成脚本”链接。

以下是我用于我们的应用程序服务器的一个简单示例。

 Set-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST' -filter "system.applicationHost/log/centralW3CLogFile" -name "logExtFileFlags" -value "Date,Time,ClientIP,UserName,SiteName,ComputerName,ServerIP,Method,UriStem,UriQuery,HttpStatus,Win32Status,TimeTaken,ServerPort,UserAgent,Referer,HttpSubStatus" 

如果这给你带来了麻烦,你也可以使用appcmd工具,像这样(更新MySiteName到你的IIS站点名称,id ='6'到你的网站的ID):

 C:\windows\system32\inetsrv\Appcmd set config -section:sites /[name='"MySiteName"',id='6'].logFile.logExtFileFlags:Date,Time,ClientIP,UserName,ServerIP,Method,UriStem,HttpStatus,Win32Status,TimeTaken,ServerPort,UserAgent,Cookie,HttpSubStatus