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.
This post has been republished via RSS; it originally appeared at: IIS Support Blog articles.
In many cases, when troubleshooting web applications hosted in IIS, we start by collecting the basics for investigation:
- The configuration of IIS and underlying HTTP.SYS, of Asp.Net and of the application, and system info.
- The logs and traces from IIS, HTTP.SYS, Windows Events. If we’re lucky, we have FREBs, Failed Request Traces.
- Problem description, to help us figure out how and where to focus during investigation.
I intend to detail in a later article why we look into those files, what we expect to see there. And my colleagues are working on a tool, a PowerShell script, to automate the data collection. But until then…
Start collecting
Many of the files are only accessible to the Administrators on the investigated machine.
So open an administrative command-line console if you’re going to use the commands below. Then…
First, create a folder where all collected files will be placed:
MKDIR C:\MsLogs
C:
CD \MsLogs
Collect HTTP.SYS configuration
netsh http show cacheparam > C:\MsLogs\netsh_http_show_cacheparam.txt
netsh http show cachestate > C:\MsLogs\netsh_http_show_cachestate.txt
netsh http show iplisten > C:\MsLogs\netsh_http_show_iplisten.txt
netsh http show servicestate > C:\MsLogs\netsh_http_show_servicestate.txt
netsh http show setting > C:\MsLogs\netsh_http_show_setting.txt
netsh http show sslcert > C:\MsLogs\netsh_http_show_sslcert.txt
netsh http show timeout > C:\MsLogs\netsh_http_show_timeout.txt
netsh http show urlacl > C:\MsLogs\netsh_http_show_urlacl.txt
Master IIS configuration — applicationHost.config
Default location is:
C:\Windows\System32\inetsrv\config\
Note: It’s better if you can send the whole folder C:\Windows\System32\inetsrv\config\.
Example:
XCOPY %systemroot%\System32\inetsrv\config\*.* C:\MsLogs\ /E
IIS Log files
Only send logs of the site containing the problematic application. Default location:
C:\inetpub\logs\LogFiles\W3SVC[siteID]\
Determine the Site ID from IIS Manager console, selecting the Sites node.
Only include latest files, if too many logs are there; we only need the investigated timeframe. For instance, logs in the last 10 days.
Example:
MKDIR C:\MsLogs\IIS-logs
ROBOCOPY C:\inetpub\logs\LogFiles\W3SVC1\ C:\MsLogs\IIS-logs\ /MAXAGE:10
FREBs, Failed Request Traces…
…if any were collected at all, related to the issue being reported.
Only send traces for the site containing the problematic application. Default location:
C:\inetpub\logs\FailedReqLogFiles\W3SVC[siteID]\
Determine the Site ID from IIS Manager console, selecting the Sites node.
Example:
MKDIR C:\MsLogs\FREBs
COPY C:\inetpub\logs\FailedReqLogFiles\W3SVC1\*.* C:\MsLogs\FREBs\
HttpErr logs
Events and errors logged by the HTTP.SYS driver, which IIS relies on. The default location:
C:\Windows\System32\LogFiles\HTTPERR\
Only include latest files, if too many logs are there; we only need the investigated timeframe. For instance, logs in the last 10 days.
Example:
MKDIR C:\MsLogs\HTTPERR
ROBOCOPY %systemroot%\System32\LogFiles\HTTPERR\ C:\MsLogs\HTTPERR\ /MAXAGE:10
The .NET configuration and root Web.config
Before executing an app, IIS is building its configuration by merging trees with settings — read «config files»: .NET FX config, then Asp.NET root Web.config, applicationHost.config of IIS, application’s local Web.config cascade (root site Web.config, then sub-application’s Web.config etc).
The .NET Framework (FX) configuration:
machine.config
The root ASP.NET configuration:
Web.config
Depending on application bitness, these can be found at:
C:\Windows\Microsoft.NET\Framework(64)\[version]\Config
Example:
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config
It’s better if you can send the whole folder.
Example:
MKDIR C:\MsLogs\ASP.NET-Config
XCOPY %systemroot%\Microsoft.NET\Framework64\v4.0.30319\Config\*.* C:\MsLogs\ASP.NET-Config\ /E
Application’s local configuration
The Web.config file(s) of the root site — and sub-application(s), if that’s the case — being diagnosed.
Or at least send the application’s effective configuration, compiled by IIS from the above config files:
C:\inetpub\temp\appPools\[appPoolName]\[appPoolName].config
Example:
COPY C:\inetpub\temp\appPools\DefaultAppPool\DefaultAppPool.config C:\MsLogs\
Windows Events Viewer entries
We’ll take the following 3 logs from Windows Events Viewer
- Application Event logs
- System Event logs
- Security Event logs
Select each of them and then…
- On the right side, pick Filter Current Log…, then only last 7 or 30 days
(make sure the period covers moment when issue was manifesting). - Then, on the right side again, pick Save Filtered Log File As… EVTX,
(make sure you include ‘Display information for these languages: English‘)
To collect entries in last 10 days, you can export them by running the following command lines:
WEVTUTIL export-log System C:\MsLogs\WinEvents-System.evtx /query:"*[System[TimeCreated[timediff(@SystemTime) <= 864000000]]]"
WEVTUTIL export-log Application C:\MsLogs\WinEvents-Application.evtx /query:"*[System[TimeCreated[timediff(@SystemTime) <= 864000000]]]"
WEVTUTIL export-log Security C:\MsLogs\WinEvents-Security.evtx /query:"*[System[TimeCreated[timediff(@SystemTime) <= 864000000]]]"
Note that timediff function returns milliseconds from now. One day means 24 hours x 60 minutes x 60 seconds x 1.000 milliseconds = 86.400.000.
IIS installation logs
Collect Component-Based Setup log file — the packages that Windows installed.
Then IIS setup logs — how the IIS instance installation went.
COPY C:\Windows\Logs\CBS\cbs.log C:\MsLogs\
COPY C:\Windows\iis.log C:\MsLogs\
System information
Export the output of MsInfo32, or simply run the command:
MsInfo32 /nfo C:\MsLogs\System-Info.nfo
MsInfo32 /report C:\MsLogs\System-Info.txt
Archive the resulting data collection folder C:\MsLogs\ in a ZIP file, then upload the archive in the file transfer space for the case.
You’ll need to send the collected data and/or share it with the engineer helping you do the troubleshooting.
Application issue details
You have to provide as much descriptive information as you can around what happens.
- Please provide the name of the site and/or application with the problem and also the Application Pool name;
- The affected URLs, possibly with screenshots or HTTP traces from client;
- Observed behavior, such as long response time, high-memory consumption or high-CPU;
- What the application is supposed to do, or what are the URLs exerting the problem are doing;
- Reproducing steps, if applicable;
- Any pattern of usage that triggers the behavior: certain time of day, certain users, certain system conditions etc.
Looking to analyze ASP.NET Application issues then here is an article which talks about where you need to look. Most of the time you will be able to analyze asp.net related application issues using the below-mentioned techniques.
IIS Logs
First make sure that you have enabled IIS logs, configured path for IIS logs, and are logging all the important/required fields for analysis. I personally prefer to select all the fields for the log. In case you need help on how to configure IIS logs then you can check this article on how to configure IIS Logs. IIS logs will typically contain a single entry for each request to the site which contains the date/time of the request, URL, query-string, response status with sub status, time-taken, and many more fields that provides details of each request. Refer here for a complete list of W3C log fields.
Error codes, in case of error, are available in status substatus and win32 status which can help identify the details of the error. Status is normal HTTP response codes like 200 means ok, 404 – not found, 500 – Internal server error mostly refers to application error (complete list of HTTP response status codes), etc. sc-win32-status can provide more details about the underlying error. IIS Logs helps to analyze asp.net application issues like failing requests, slow requests, etc.
Also, the Log Parser tool from Microsoft can be used to read and analyze IIS logs. Download Log Parser 2.2
HTTPERR Logs
You should be able to locate your request in IIS logs but in case even after enabling your IIS logs your request is not present in IIS logs then there is a possibility that the request never reached IIS so you need to also look in HTTPERR logs. Any incoming request to the webserver is first handled by HTTP.SYS before being routed to the IIS worker process. Some requests are rejected by HTTP.SYS before being passed to an IIS worker process for handling. This generally happens in case of errors like Bad Request (400), connection timeouts, service unavailable (503), and many more. Here is the complete list of HTTP.SYS error codes.
HTTPERR logs help to Analyze ASP.NET Application Issues by providing details of an error at the request level which helps in identifying issues at each request level.
HTTPERR logs can be found on path C:\Windows\System32\LogFiles\HTTPERR
Windows Event Logs
Request in IIS logs with status 500 i.e. Internal server error is mostly related to unhandled ASP.NET Application errors. If configured properly and if there are no compatibility issues with the health monitoring feature then, in that case, there are chances that error details might have been logged to the windows event log. Health Monitoring will log all errors to the application event log. Specifically, look for warning events from the source “ASP.NET “. One point to note here is that errors written to EventLog are limited i.e. it will only log one error per minute.
Also, it will be helpful to scan event logs around the error time to get some insights if there are any other errors/warnings related to Windows/Disk/CPU/Memory which might be causing an error in the Application.
Failed Request Tracing
This will help you capture a detailed request trace for a specific URL, status code or time-taken. Will provide details to determine what is happening with request and why, provided the problem can be simulated. Problems that are random in nature are difficult to troubleshoot unless you are able to capture trace when the problem occurs.
Request trace is very detailed and sometimes it might take lots of time to analyze a single request.
Display ASP.NET Exception
On a temporary basis, you can enable your application to display a complete exception in the browser to identify the exact cause of the problem.
For this, we can need to add a customErrors tag within the web.config configuration file located in the root directory of the application. The <customErrors> tag should have its mode attribute set to off. ‘off’ Specifies that custom errors are disabled & detailed ASP.NET errors are shown to the remote clients and to the localhost.
<customErrors defaultRedirect="url" mode="On|Off|RemoteOnly"> <error. . ./> </customErrors>
Remember that this setting i.e. custom errors should always be set to mode ‘on’ & should be enabled for debugging purposes only.
DebugDiag for Crash/Hang, Memory & Performance Analysis
To Analyze ASP.NET Application Issues DebugDiag can be used. DebugDiag is a free tool from Microsoft with capability that allows us to collect & analyze memory dump files. Dumps can be generated in 2 ways i.e. conditional or on-demand collections of memory dump files using configurable rules that trigger the collection.
DebugDiag download link: https://www.microsoft.com/en-us/download/details.aspx?id=58210
To a collect memory dump file on-demand
- Run the DebugDiag 2.3 Collection tool.
- Go to the Processes tab, Identify the process (e.g. using process ID) which needs to be analyzed.
- Right-click on the required process and select the Create Full Userdump option from Menu.
To analyze the memory dump file
- Run DebugDiag Analysis tool
- Click add data files and add dump files which need to be analyzed.
- Under analysis select type of analysis required and click start analysis.
- It will generate a Report (mht file) that can be reviewed for details.
Conclusion
We reviewed various techniques to analyze asp.net application issues & these techniques have personally helped me to resolve many ASP.NET web application related issues. DebugDiag has been a great help to identify issues such as the hang process.
Hope you found this article useful. Please support the Author
June 26th at 12:00am
For quick reference, I’m posting the Default IIS log file locations for Windows Server 2003 and 2008.
Windows 2003:
- HTTP Log file location: C:\WINDOWS\system32\LogFiles\W3SVC1
- HTTP ERR (ERROR) log file location: c:\Windows\System32\LogFiles\HTTPERR
Windows 2008:
- HTTP Log file location: c:\inetpub\logs\LogFiles\W3SVC1
- HTTP ERR location: c:\Windows\System32\LogFiles\HTTPERR
Recent Posts
- Updating a 5 Year Old Android To Build With Android Studio 2024.1.2
- VLAN Configuration across Mikrotik CRS310 and OPNSense 24.7.2
- A Bash one-liner for printing GIF comics emailed from gocomics
- Adventures in Installation: VMware Workstation 17.5.2 on Ubuntu 24.04
- Backup and Restore — Migrate — Signal Desktop Messages (Linux/Ubuntu)
© 7th Zero. All rights reserved.
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