Provide feedback
Saved searches
Use saved searches to filter your results more quickly
Sign up
Microsoft Internet Information Services (IIS) is a popular web server used on Windows platforms to host websites, web applications, and services. Understanding how IIS handles logging is crucial for optimizing server performance, troubleshooting issues, and enhancing security.
IIS primarily maintains two types of logs:
- Access Logs – Track incoming HTTP requests to your server.
- Error Logs – Record server-side errors, failed requests, and application-level issues.
This guide will walk you through the structure, configuration, and practical use of both types of logs in IIS.
Log & Configuration File Locations
Before getting into the details, it’s helpful to understand where IIS stores its logs and configuration files.
Description | Location |
---|---|
Access Logs | C:\inetpub\logs\LogFiles\W3SVC<SiteID>\ |
Failed Request Logs | C:\inetpub\logs\FailedReqLogFiles\W3SVC<SiteID>\ |
Error Logs (Event Viewer) | Windows Event Viewer > Applications and Services Logs |
IIS Configuration | C:\Windows\System32\inetsrv\config\applicationHost.config |
Understanding IIS Access Logs
What Are Access Logs?
Access logs capture details of all incoming HTTP requests processed by IIS. They are invaluable for:
- Monitoring traffic patterns
- Identifying potential security threats
- Analyzing client behavior (e.g., pages visited, user agents)
Enabling and Configuring Access Logs
To enable and configure access logging in IIS:
- Open IIS Manager:
- Navigate to Sites > Your Website.
- Double-click Logging under the IIS section.
- Configure Log Settings:
- Format: The default format is W3C, which records critical request data.
- Log File Directory: Typically located in
C:\inetpub\logs\LogFiles\
. - Fields: You can customize which fields to log (e.g., client IP, user agent, status code).
- Customizing Log Fields
- Click on Select Fields to include or exclude specific details like the referrer, server port, or HTTP substatus.
Access Log Format
IIS uses the W3C extended log format, which includes details like the client IP, HTTP method, URL, and status codes.
Sample Access Log Entry:
#Fields: date time cs-method cs-uri-stem sc-status sc-bytes cs(User-Agent) c-ip
2024-11-14 10:15:23 GET /index.html 200 4523 "Mozilla/5.0" 192.168.1.10
Field | Description |
---|---|
date |
Date of the request |
time |
Time of the request |
cs-method |
HTTP method (GET, POST, etc.) |
cs-uri-stem |
Requested URL path |
sc-status |
HTTP status code |
sc-bytes |
Size of the response sent to the client |
cs(User-Agent) |
Client’s browser information |
c-ip |
Client IP address |
Understanding IIS Error Logs
What Are Error Logs?
Error logs capture issues that occur while IIS processes requests. These logs are crucial for diagnosing server errors, application crashes, and configuration problems.
Types of IIS Error Logs
IIS uses multiple sources for logging errors:
- HTTP Error Logs:
- Located in
C:\inetpub\logs\LogFiles\W3SVC<SiteID>
. - Capture HTTP errors such as 404 (Not Found) or 500 (Internal Server Error).
- Located in
- Failed Request Tracing (FREB) Logs:
- Provide detailed information on failed requests.
- Located in
C:\inetpub\logs\FailedReqLogFiles\W3SVC<SiteID>\
. - To enable, go to IIS Manager > Failed Request Tracing Rules.
- Windows Event Viewer:
- Captures system-level errors, application crashes, and critical events.
- Access via Event Viewer > Windows Logs > Application or System.
Configuring Error Logs
To enable Failed Request Tracing:
- Open IIS Manager and select your website.
- Click on Failed Request Tracing.
- Enable the feature and set the number of trace files to keep.
- Define specific conditions to capture, such as status codes (e.g., 500 errors).
Sample Error Log Entry (FREB)
<Event>
<DateTime>2024-11-14T10:20:45.123Z</DateTime>
<SiteID>1</SiteID>
<RequestStatus>500</RequestStatus>
<FailureReason>Module_Detail_Error</FailureReason>
<ModuleName>FastCgiModule</ModuleName>
<ErrorCode>0x8007000d</ErrorCode>
<URL>/api/data</URL>
<ClientIP>192.168.1.15</ClientIP>
</Event>
Explanation:
- The error log indicates a 500 Internal Server Error due to an issue with the FastCGI module.
Common Error Types
Here are some common IIS error messages:
Error Code | Description |
---|---|
400 |
Bad Request – Malformed request sent by the client |
401 |
Unauthorized – Authentication required |
403 |
Forbidden – Access denied |
404 |
Not Found – Resource not found |
500 |
Internal Server Error – Application or server error |
503 |
Service Unavailable – Application pool is stopped |
Configuring Logs for Multiple Websites
If you are hosting multiple websites on the same IIS server, it’s useful to configure separate logs for each site:
- In IIS Manager, select the site you want to configure.
- Open Logging and specify a unique log directory.
- Adjust the settings to include or exclude specific fields as needed.
Example:
- Site 1: Logs stored in
C:\inetpub\logs\LogFiles\W3SVC1\
- Site 2: Logs stored in
C:\inetpub\logs\LogFiles\W3SVC2\
Mastering IIS logs is essential for maintaining a stable and secure web environment. By properly configuring and analyzing access and error logs, you can optimize server performance, identify issues quickly, and enhance security.
Use this guide to improve your IIS logging setup and server management capabilities.
Learn about the 4 various log sources you need to know when tracking down ASP.NET request errors.
Your web application is throwing some sort of error or invalid response. Do you know how to troubleshoot IIS or ASP.NET errors on your servers? Luckily, Windows & ASP.NET provide several different logs where failed requests are logged.
You are probably familiar with normal IIS logs, but there are some other places to look if you are looking for more detailed error messages or can’t find anything in your IIS log files.
1. Standard IIS Logs
Standard IIS logs will include every single web request that flows through your IIS site. Via IIS Manager you can verify that your IIS logs are enabled and where they are being written to.
You should find your logs in folders that are named by your W3SVC site ID numbers.
By default each logged request in your IIS log will include several key fields including the URL, querystring, and error codes via the status, substatus and win32 status. These status codes can help identify the actual error in more detail.
#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 - 500 0 0 5502 2016-09-13 21:45:10 ::1 GET /favicon.ico - 80 - ::1 Mozilla/5.0 http://localhost/webapp2 404 0 2 4
The “sc-status” and “sc-substatus” fields are the standard HTTP status code of 200 for OK, 404, 500 for errors, etc.
The “sc-win32-status” can provide more details that you won’t know unless you lookup the code. They are basic Win32 error codes.
2. Can’t find your request in the IIS log? HTTPERR is your IIS error log
Every single web request should show in your IIS log. If it doesn’t, it is possible that the request never made it to IIS, or IIS wasn’t running. Also, be sure that your IIS logging is enabled.
Incoming requests to your server first route through HTTP.SYS before being handed to IIS. These type of errors get logged in HTTPERR. Common errors are 400 Bad Request, timeouts, 503 Service Unavailable and similar types of issues. The built in error messages and error codes from HTTP.SYS are usually very detailed.
Where are the HTTPERR error logs?
C:\Windows\System32\LogFiles\HTTPERR
3. Look for ASP.NET exceptions in Windows Event Viewer
By default ASP.NET will log unhandled 500 level exceptions to the Windows Application EventLog. This is handled by the ASP.NET Health Monitoring feature. You can control settings for it via system.web/healthMonitoring in your web.config file.
Very few people realize that the number of errors written to the Application EventLog is rate limited. So you may not find your error! By default it will only log the same type of error once a minute. You can also disable writing any errors to the Application EventLog.
Still can’t find your exception?
Depending on if you are using WebForms, MVC, Web API, WCF or other frameworks, you may have issues with ASP.NET not writing any errors at all to ASP.NET due to compatibility issues with the health monitoring feature.
4. Enable Failed Request Tracing for an advanced IIS error log
Failed request tracing (FRT) is probably one of the least used features in IIS. It provides robust IIS logging and works as a great IIS error log. FRT is enabled in IIS Manager and can be configured via rules for all requests, slow requests, or just certain response status codes.
The only problem with FRT is it is insanely detailed. It tracks every detail and every step of the IIS pipeline. You can spend a lot of time trying to decipher a single request.
When you investigate IIS or ASP.NET errors in production, does IIS sometimes feel like a black box?
Learn to use these 4 server logs, and you will always find the error you are looking for.
Its gotta be here somewhere
Finding the error is actually fairly straightforward once you know where to look. Most of the time, the error will be in one of these 4 logfiles by default:
1. First stop: the IIS log
The website’s IIS log will contain an entry for every request to the site. This log is typically located in c:inetpublogsLogFilesW3SVC[SITEID]. For each logged request, the log includes the URL, querystring, and the response status and substatus codes that describe the error:
2013-06-16 03:39:19 ::1 GET /test.aspx mincase=80 80 - ::1 - 500 16 0 3173
Tip: Notice the 500 16 0? These are the HTTP response status code, the IIS substatus code, and the win32 error code. You can almost always map the status and substatus code to an error condition listed in IIS7 HTTP error codes. You can also look up the win32 error code via winerror.h.
Is the substatus code 0, esp. 500.0? Then its most likely an application error i.e. ASP.NET, ASP, PHP, etc.
2. Nothing in the IIS log? Check the HTTPERR log
Sometimes, the request will not listed in the IIS log. First make sure that IIS logs are enabled for the website.
In a small percentage of cases, the request may have been rejected by HTTP.SYS before it even made it to an IIS worker process. This generally happens if the request violated the HTTP protocol (client saw HTTP 400: Bad Request) or there was a WAS/the application pool failure (client saw HTTP 503: Service Unavailable).
In this case, you will find the error in the HTTPERR logs, located in c:windowssystem32LogFilesHTTPERR:
2011-01-11 13:08:22 192.168.1.75 52623 192.168.1.124 2869 HTTP/1.1 NOTIFY /upnp/eventing/pfyehnxzvy - - Connection_Abandoned_By_ReqQueue
Tip: See the Connection_Abandoned_By_ReqQueue? HTTP.SYS is even better than IIS at telling you exactly why the error happened. See HTTP.SYS error codes for the exact cause.
3. ASP.NET exceptions: the Application EventLog
If the request is to an ASP.NET application, and the error was a 500.0, its most likely an unhandled ASP.NET exception. To find it, go to the Application EventLog and look for Warning events from the ASP.NET 4.0.30319.0 or applicable version:
Tip: ASP.NET Health Monitoring will log all errors to the Application EventLog by default. Except 404s. Also, it will only log up to 1 exception per minute. And logging is broken in ASP.NET MVC apps (sigh). Not to worry, here is a way to fix to reliably log ASP.NET exceptions.
4. Hard-to-catch errors: the Failed Request Trace (FRT) log
Can’t seem to catch the error? It it gone from the log before you can get to it? Then you need the IIS Failed Request Trace feature. This will let you configure a rule to capture a detailed request trace for a specific URL, status code, or time elapsed. Learn how to set up Failed Request Tracing to capture IIS errors.
Get ahead of the error game
If you are reacting to user error reports, you are already behind the 8-ball. The reality is, majority of production errors go unreported, because users are reluctant to speak up when they hit problems on your site. Given the short attention spans and low patience these days, they are way more likely to stop using your site instead. By the time you find out you have errors, the damage has already been done.
The only way to really win this game is to get proactive, and continually monitor all errors in your application so you can triage/fix the ones you consider important … BEFORE users begin to notice. If this sounds hard, it doesn’t have to be – esp. if you use LeanSentry’s error monitoring. Give it a try and never worry about hunting for errors again.
Incoming server requests are first routed through HTTP.SYS, and then to IIS servers. An IIS access log should record every single web request. If a web request isn’t recorded, it’s possible that either the request never made it to the IIS server or the IIS server wasn’t running. In such cases, these errors are logged in HTTPERR; 400, 503, and 504 are some of the most common errors you’ll find in IIS error logs. Learn more about log management with Site24x7.
Getting started
- Log in to your Site24x7 account.
- Download and install the Site24x7 Server Monitoring agent (Windows).
- Go to Admin > AppLogs > Log Profile and Add Log Profile.
Log file path
Each application writes logs in different folders and files. By default, IIS error logs are sourced from the folder path mentioned below. If you have logs in a different folder, you can add them under the File Path to source them from that particular folder while creating a log profile.
:
C:\System32\LogFiles\HTTPERR\httperr*.log
Log pattern
$DateTime:date$ $ClientIP$ $ClientPort:number$ $ServerIP$ $ServerPort:number$ $ProtocolVersion$ $Method$ $RequestUri$ $StatusCode:number$ $SiteId$ $Reason$ $QueueName$
This is the default log pattern defined by Site24x7 for parsing IIS error logs.
Sample log
2018-08-20 21:42:28 192.168.218.147 42294 172.21.9.17 80 HTTP/1.1 POST /sites/sachin/_vti_bin/sites.asmx 404 — NotFound —
The above sample log can be separated into 12 fields, each of which will take its respective value from the original log, and then be uploaded to Site24x7.
Field name | Filed value |
Date Time | 2018-08-20 21:42:28 |
Client IP | 192.168.218.147 |
Client Port | 42294 |
Server IP | 172.21.9.17 |
Server Port | 80 |
Protocol Version | HTTP/1.1 |
Method | POST |
Request URI | /sites/sachin/_vti_bin/sites.asmx |
Status Code | 404 |
Site ID | — |
Reason | NotFound |
Queue Name | — |
IIS error logs dashboard
AppLogs creates an exclusive dashboard for every Log Type, and shows a few widgets by default. Here’s a list of the widgets available in the IIS error logs dashboard:
- Top 20 Failed Requests
- Top Failed Reasons
- Status Codes
- HTTP Methods
Note
In addition to the default widgets, your saved searches will also be added to the dashboard automatically.
- IIS access logs
- Log4net logs
- NLog logs
- Other supported log types
-
On this page
- Getting started
- Log file path
- Log pattern
- Sample log
- IIS error logs dashboard
- Related log types