Microsoft’s IIS web server uses a non-standard file format that is rarely seen. IIS Log Files use a space-delimited file format and also contain comments in them. The column headings are defined in the comments. In this article, we are going to take a look at how to interpret IIS log files.
By the way, if you need help finding your IIS log files, be sure to check out our guide dedicated to that topic: Where Are IIS Log Files Located? How to View IIS Logs on Windows & Azure
How to Interpret the IIS Log File Format
Here are a few of the key things you need to know:
- IIS may write separate files by day, by hour, and by IIS site (there are settings for this)
- Lines that start with a # are comments
- Everytime IIS restarts it will write to the log file the current version, date, and fields as shown below
- The file is in a space delimited file format
- Fields that have no value will show a dash (-) since spaces are not allowed
An example of the column headings and one line. It shows here with a line break in it because it’s so long. You can see the real file in the screen also shown here.
#Fields: date time s-ip cs-method cs-uri-stem cs-uri-query s-port cs-username c-ip cs(User-Agent) cs(Referer) sc-status sc-substatus sc-win32-status time-taken 2016-09-13 21:45:10 ::1 GET /webapp2 - 80 - ::1 Mozilla/5.0+(Windows+NT+10.0;+Win64;+x64)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/52.0.2743.116+Safari/537.36 - 500 0 0 5502
Common IIS Log File Fields
|Field||Appears As||Description||Default Y/N|
The date on which the activity occurred.
The time, in coordinated universal time (UTC), at which the activity occurred.
Client IP Address
The IP address of the client that made the request.
The name of the authenticated user who accessed your server. Anonymous users are indicated by a hyphen.
Service Name and Instance Number
The Internet service name and instance number that was running on the client.
The name of the server on which the log file entry was generated.
Server IP Address
The IP address of the server on which the log file entry was generated.
The server port number that is configured for the service.
The requested action, for example, a GET method.
The target of the action, for example, Default.htm.
The query, if any that the client was trying to perform. A Universal Resource Identifier (URI) query is necessary only for dynamic pages.
The HTTP status code.
The Windows status code.
The number of bytes that the server sent.
The number of bytes that the server received.
The length of time that the action took, in milliseconds.
The protocol version —HTTP or FTP —that the client used.
The host header name, if any.
The browser type that the client used.
The content of the cookie sent or received if any.
The site that the user last visited. This site provided a link to the current site.
The sub status error code.
How to Customize IIS Log Files
IIS provides a few settings for customizing your IIS log files within the IIS Manager console. You can log them in the default W3C format or use IIS, NCSA or custom file formats.
You also have the ability to specify how the log files rollover. This determines if a new file is created hourly, daily, weekly, etc. You can also specify a max file size instead.
The fields that are being logged can also be customized. You may remove fields that you don’t need, select from some optional fields or even create your own. The custom fields should be values that are available in the HTTP headers or from the server variables.
How to Read IIS Log Files With Log Parser Studio
If you want to open the IIS log files in log file viewer, I would suggest using the free Log Parser Studio from Microsoft. If you want to query your logs from command line only, you can also use Log Parser 2.2, which has no UI.
When you open Log Parser Studio you can pick from a wide array of pre-built queries. I would suggest skipping that and follow these steps:
- File -> New Query
- Select where your log files are
- Set the log type of IISW3CLOG
Once you have specified your log file location and the type of logs, you are ready to query your IIS log files.
Here is a basic query to get you started:
SELECT TOP 1000 * FROM '[LOGFILEPATH]' ORDER BY time-taken
LogParser supports a SQL-like syntax which can be used to do very powerful queries and reporting. Check out this website which lists 50 different queries as examples.
With Log Parser Studio you can also export the data to a CSV file which could be used via Excel or other tools.
How to Leverage Log Management to Interpret IIS Log Files
If you want to get the most of your IIS log files, you will want to aggregate them within a log management service. These tools can help you view and query them in real time, across all of your servers. Log management is included as one of the features of Retrace.
Log management advantages:
- Search across all servers
- Archival of log data
- Monitor logs for potential problems
- Provide easy access to all of IT
Screenshot of Retrace log viewer
In this article about how to interpret IIS logs, we reviewed the format of the files, how to customize them, how to query them, and even how to aggregate them all with a log management solution.
- ASP.NET Performance Monitoring: A Developer’s How to Guide - August 18, 2017
- When & How to Use Custom Application Metrics - August 17, 2017
- ASP.NET Razor Pages vs MVC: How Do Razor Pages Fit in Your Toolbox? - August 16, 2017
- .NET Core 2.0 Changes – 4 Key Things to Know - August 14, 2017
- Why Developers Love Cloud Logging Services - August 1, 2017