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
). 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. I couldn't find any way to change these configuration for IIS Express. Is there anyway to define the fields I want to include in the log in IIS express?
Either using a GUI like the Logging
in IIS configuration, Command line code, or just editing a configuration file?
I found the IIS Express logFile configuration but in there, but couldn't find anything about adding the fields there:
%userprofile%\\documents\\iisexpress\\config\\applicationhost.config
which has logFile configuration in SiteDefaults
:
<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. It can either be defined in <siteDefaults>
to apply the same settings to all sites, or it can be defined for each <site>
section.
To configure the default categories, you can use the logExtFileFlags
attribute:
The logExtFileFlags attribute can be one or more of the following values. If you specify more than one value, separate them with a comma (,).
In your case, you'll want Host
, BytesRecv
and BytesSent
.
To add custom fields, you can use the <customFields>
subsection.
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>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.