简体   繁体   English

在 IIS Express 中配置日志文件字段

[英]Configuring log file fields in IIS Express

I'm dealing with log files and calculating the traffic usage of each website.我正在处理日志文件并计算每个网站的流量使用情况。 The default logging is missing my required fields ( cs-host , sc-bytes , cs-bytes ).默认日志记录缺少我的必填字段( cs-hostsc-bytescs-bytes )。 While I'm able to change these configuration in Logging section of IIS which I can select the fields I want to include or exclude in my logging.虽然我可以在 IIS 的Logging部分更改这些配置,但我可以选择要在日志记录中包含或排除的字段。 I couldn't find any way to change these configuration for IIS Express.我找不到任何方法来更改 IIS Express 的这些配置。 Is there anyway to define the fields I want to include in the log in IIS express?无论如何要定义我想包含在 IIS express 日志中的字段?

Either using a GUI like the Logging in IIS configuration, Command line code, or just editing a configuration file?是使用像Logging IIS 配置、命令行代码这样的 GUI,还是只是编辑配置文件?

IIS日志文件配置

I found the IIS Express logFile configuration but in there, but couldn't find anything about adding the fields there:我在那里找到了 IIS Express logFile 配置,但找不到任何关于在那里添加字段的信息:

%userprofile%\\documents\\iisexpress\\config\\applicationhost.config

which has logFile configuration in SiteDefaults :SiteDefaults有 logFile 配置:

<siteDefaults>
    <logFile logFormat="W3C" directory="%IIS_USER_HOME%\Logs"/>
    <traceFailedRequestsLogging directory="%IIS_USER_HOME%\TraceLogFiles" enabled="true" maxLogFileSizeKB="1024" />
</siteDefaults>

To have a complete answer: you must first locate the applicationhost.config that corresponds to your site, and then edit the <logFile> section.要获得完整的答案:您必须首先找到与您的站点对应的applicationhost.config ,然后编辑<logFile>部分。 It can either be defined in <siteDefaults> to apply the same settings to all sites, or it can be defined for each <site> section.它可以在<siteDefaults>定义以将相同的设置应用于所有站点,也可以为每个<site>部分定义。

To configure the default categories, you can use the logExtFileFlags attribute:要配置默认类别,您可以使用logExtFileFlags属性:

The logExtFileFlags attribute can be one or more of the following values. logExtFileFlags属性可以是以下值中的一个或多个。 If you specify more than one value, separate them with a comma (,).如果指定多个值,请用逗号 (,) 分隔它们。

In your case, you'll want Host , BytesRecv and BytesSent .在您的情况下,您需要HostBytesRecvBytesSent

To add custom fields, you can use the <customFields> subsection.要添加自定义字段,您可以使用<customFields>小节。

Here's a complete example:这是一个完整的例子:

<logFile logFormat="W3C" directory="%AppData%\Microsoft\IISExpressLogs" 
 enabled="true" flushByEntryCountW3CLog="2" 
 logExtFileFlags="Host, BytesRecv, BytesSent">
  <customFields>
    <add logFieldName="custom-UUID" sourceType="RequestHeader" sourceName="UUID" />
  </customFields>
</logFile>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM