Iis logs 500 error

I have a desktop application that makes a call to an asp page on the web server. The web server is currently returning a 500 server error and I cannot figure out how to get more detail. There doesnt

I have a desktop application that makes a call to an asp page on the web server. The web server is currently returning a 500 server error and I cannot figure out how to get more detail.

There doesnt seem to be anything in the Event Viewer: Windows Logs->application.

Is there a setting I can make or another place I can find logs? Seems like this would be a typical issues but I cannot find any information on this.

(Also, the stack trace does not come through to the client application)

asked Dec 30, 2014 at 22:55

user1373121's user avatar

1

You can enable «trace logging» on IIS Manager. It fill create bunch of XML files you can easily investigate using IE installed on the server. (other browsers may fail to process xslt style files)

From Technet:

  1. Open IIS Manager and navigate to the level you want to manage. For information about opening IIS Manager, see IIS 7.0: Open IIS Manager. For information about navigating to locations in the UI, see IIS 7.0: Navigation in IIS Manager.
  2. In the Connections pane, click Sites.
  3. In Features View, select the site for which you want to enable trace logging.
  4. In the Actions pane, under «Configure, click Failed Request Tracing.
  5. In the Edit Web Site Failed Request Tracing Settings dialog box, select Enable to enable logging for this site.
  6. In the Directory text box, type the path where you want to store the log files or click the browse button (...) to find a location on the computer. The default is %SystemDrive%inetpublogsFailedReqLogFiles.
  7. In the Maximum number of trace files text box, type the maximum number of trace log files that you want to keep, and then click OK.

enter image description here

PS: don’t bother IIS 7.0, almost same as IIS 8.x

Owen Blacker's user avatar

Owen Blacker

4,0972 gold badges36 silver badges70 bronze badges

answered Dec 30, 2014 at 23:05

atakan's user avatar

atakanatakan

6954 silver badges11 bronze badges

6

This should be a comment but comments don’t let me add an image.

This is a screenshot of Matt Browne’s comment. Upvote his comment if you find this helpful.

If you don’t see the «Failed Request Tracing Rules» button, then you need to enable «Tracing» tracing in Server roles.

Here it is:

enter image description here

There is also this configuration that needs to be set:

enter image description here

I had to restart my machine in order for the server configuration to be recognized in IIS.

answered Sep 17, 2018 at 17:45

Be Kind To New Users's user avatar

1

  • Remove From My Forums
  • Question

  • User1538345531 posted

    Hi,

    I have come up with a strange issue. I have run into a problem while i call .aspx page via http from another application.The IIS server logs an entry with 500 code. As I am just logging an entry into one log file with some message on pageload event of the .aspx
    page..Previously i was having .asp page and it was executed as expected. 

    I dont know weather the problem is with .aspx page or with some configuration if any?

    Hi,

    I have come up with a strange issue. I have run into a problem while i call .aspx page via http from another application.The IIS server logs an entry with 500 code. As I am just logging an entry into one log file with some message on pageload event of the
    .aspx page..Previously i was having .asp page and it was executed as expected. 

    I dont know weather the problem is with .aspx page or with some configuration if any?

Answers

  • User372121194 posted

     Hi,

    The error 500 code means that server encounters internal error and your ASP.NET website has not been executed yet, so the log entry in PageLoad event is not logging.

    In this case, please make sure your server can serve ASP.NET application. We need to configure the ASP.NET version on IIS, etc. For more information, see Deploying ASP.NET Applications (http://aspalliance.com/1464_Deploying_ASPNET_Applications.all).

    I look forward to receiving your test results.

    • Marked as answer by

      Thursday, October 7, 2021 12:00 AM

You try to load your classic ASP (Active Server Pages) website and all you can see in your browser is the all too familiar display of 500 Internal Server Error.

This page isn't working

WEBSITE is currently unable to handle this request

HTTP ERROR 500

IIS HTTP Error 500 Display on Chrome browser

What is 500 Internal Server Error

First of all, the 500 Internal Server Error is a very general HTTP status code that indicates something has gone wrong on the web server without any specifics on the exact problem.

This instruction is limited to solving a 500 error on IIS server for classic ASP websites, however some other instructions that’s related to IIS in general will help for troubleshooting IIS server for .NET applications as well.

As 500 Server Error message is very often vague, the task now is to find a more specific error message that will help us further analyze and troubleshoot the issue.

Enable Debugging and Send Errors to Browser

If the website is not in a production environment, the easiest way to do it is to enable the ASP Debugging Properties and send the errors to the browser by following these steps:

  1. Launch Internet Information Services (IIS) Manager and on the left pane, select your ASP website and click on the ASP icon (Configure properties for ASP applications).

    IIS settings to configure properties for ASP applications

  2. Under the ASP window, expand the Debugging Properties and set Enable Client-side Debugging, Enable Server-side Debugging, and Send Errors To Browser to True and click Apply.

    IIS ASP Debugging Properties settings to browser

Now, when you refresh your ASP website, you will see a more descriptive error message on your browser such as the following example:

System.Xml error '80131509'

There is an error in the XML document.

/itnota/failed-page.asp, line 289

ASP 500 Error detailed failed page

With this information, you can right away open the file (e.g., itnota/failed-page.asp) and check line number 289. Again, this option is not recommended for a production website that’s still actively used and available for public since it exposes too much information publicly. The ideal way to do it is to replicate your production environment on a staging and try to reproduce the error on a lower environment.

Check IIS Log

Another way to check 500 Internal Server Error for your ASP website is by viewing IIS error logs. This is especially true if your ASP website is a public website.

Where to find the IIS Logs?

By default, the log for your website is stored on %SystemDrive%inetpublogsLogFile, but you should not use this settings for a production environment. Always set a custom path for your logs so your websites are easier to maintain in the long run. If you have a different physical hard drive for logs, even better. Make sure it’s set to Enabled.

IIS Log properties

For the sake of example, the log files are located in folder D:LogsITNota.com:

From the IIS log example below, the easiest way is to look for a pipe character (“|”) on the date and time when the error happens.

IIS Log 500 Error

The error message can be broken down into two parts:

  1. /itnota/failed-page.asp id=2087216&catId=749272

  2. |289|80131509|There_is_an_error_in_the_XML_document.

The first part indicates the problematic file with its parameters which can be reconstructed by replacing the white space with a question mark (“?”) like so:

  /itnota/failed-page.asp?id=2087216&catId=749272

The second part which starts with a pipe character (“|”) is the line number that caused the error, the error code, and the error description:

  |289|80131509|There_is_an_error_in_the_XML_document.

From the above information, we are looking at the following information:

Item Description
Filename /itnota/failed-page.asp
Line number 289
Error code 80131509
Error description There_is_an_error_in_the_XML_document.

Check the affected file by opening it in Visual Studio Code or any IDE.

If you use Visual Studio Code to read and write ASP or VBScript, click here for a way how to colorize your ASP code.

I’ve just deployed an update to an existing ASP.NET MVC3 site (it was already configured) and I’m getting the IIS blue screen of death stating

HTTP Error 500.0 — Internal Server Error
The page cannot be displayed because an internal server error has occurred.

However; there is nothing showing up in the Application Event Log where I would expect to see a (more) detailed description of the entry.

How can I go about diagnosing this issue?

asked Jul 15, 2012 at 21:25

Greg B's user avatar

Greg BGreg B

1,5585 gold badges17 silver badges32 bronze badges

1

Take a look at IIS7’s Failed Request Tracing feature:

Troubleshooting Failed Requests Using Tracing in IIS 7
Troubleshoot with Failed Request Tracing

The other thing I would do is tweak your <httpErrors> setting because IIS may be swallowing an error message from further up the pipeline:

<configuration>
  <system.webServer>
    <httpErrors existingResponse="PassThrough" />
  </system.webServer>
</configuration>

If the site is written in Classic ASP then be sure to turn on the Send Errors to Browser setting in the ASP configuration feature:

enter image description here

And finally, if you’re using Internet Explorer then make sure you’ve turned off Show friendly HTTP error messages in the Advanced settings (though I suspect you’ve done that already or are using a different browser).

answered Jul 15, 2012 at 22:10

Kev's user avatar

KevKev

7,79717 gold badges79 silver badges108 bronze badges

2

In my case:

  • The Event Log was empty.
  • web.config wasn’t corrupt — verified by using same on local machine / using inetmgr

Finally…

  • Checking IIS logs showed a request like this

...Chrome/57.0.2987.133+Safari/537.36 500 19 5 312

The key being:

sc-status sc-substatus sc-win32-status
500 19 5

which with some googling pointed me to the IIS_USRS not having read permissions to the www folder

answered May 16, 2017 at 23:25

fiat's user avatar

fiatfiat

77711 silver badges16 bronze badges

1

The most obvious issue is improper or zero NTFS rights on the web application folder. So make sure the account serving the site has the right permissions. Without proper NTFS rights to the web directory it doesn’t matter what you put in the web.config as it will never be read.

A quick check can be to give everyone full rights — if the site starts working then you know it’s a rights problem and you can then set about assigning appropriate rights to a more appropriate account.

answered Sep 10, 2016 at 22:33

rism's user avatar

rismrism

3012 silver badges12 bronze badges

If upgrading from IIS6, then it may be one of the the web.config works on 6, but not in IIS 7.5 … Double click on all the icons in IIS for the website and you may get an error about the format (Section must be below other section…)

answered May 13, 2013 at 22:11

M Hall's user avatar

I had the same problem with an Azure Web App. While debugging locally, error messages (JSON) returned from ajax calls were fully returned to the browser. But once deploy to the Web App, the messages were swallowed and i was returned a default 500 error message.
So I had to explicitly set the existingResponse value to PassThrough in the web.config httpErrors tag.

Andrew Urquhart's user avatar

answered Dec 23, 2015 at 8:45

Loul G.'s user avatar

I ran in this issue many times. 500 error from a ASP.NET 4.x website. No details in the eventLog and even the tracing above didn’t help. In my case it was caused by the fact that the web.config contains rewrite rules. So check your web.config if it has something like:

<system.webServer>
  <rewrite>
    <rules>
      ...
    </rules>
  </rewrite>
</system.webServer>

If it does, you need to install iis rewrite module:

https://www.iis.net/downloads/microsoft/url-rewrite

answered Dec 1, 2021 at 10:47

Maarten Kieft's user avatar

If your Internet Information Services (IIS) produces a 500 – Internal server error, your website is in serious trouble. Debugging an IIS 500 – Internal server error can take some time, so you’d better be prepared for the worst-case scenario. You don’t want to research how to deal with this error under time pressure.

Contents

  1. Cause of 500 – Internal server error
  2. Debugging an IIS 500 – Internal server error
  3. Resolving an IIS 500 – Internal server error
  4. Common 500.x substatus codes
  • Author
  • Recent Posts

Surender Kumar has more than twelve years of experience in server and network administration. His fields of interest are Windows Servers, Active Directory, PowerShell, web servers, networking, Linux, virtualization, and penetration testing. He loves writing for his blog.

Latest posts by Surender Kumar (see all)

  • Extending LVM space in Ubuntu — Thu, Feb 2 2023
  • Backup in Proxmox VE — Thu, Jan 26 2023
  • Snapshots in Proxmox VE — Wed, Jan 25 2023

In my previous posts, you learned about detailed errors and failed request tracing in IIS (Internet Information Server). I recommend reading those articles first before you proceed with this one.

Cause of 500 – Internal server error

This is the most common error you will encounter with any website hosted with IIS. In most cases, a developer messed up. Thus, the fastest way is often to simply reverse the last action taken, such as restoring an earlier version of your web application. Once your system is running again, you can investigate the cause of the error on your test side in peace.

500 Internal server error

500 Internal server error

The HTTP 500 error is a server-side error. While we understand that the problem is on the server end, the error is usually ambiguous. It doesn’t exactly tell the administrator what is wrong with the server. Thus, debugging a 500 – Internal server error often takes some time.

Debugging an IIS 500 – Internal server error

Since the above error doesn’t really tell what’s actually wrong with the server, we need to enable detailed errors, as discussed in my previous post. Once detailed errors are enabled, you will see more detailed error information, including an HTTP substatus code. Sometimes even the detailed errors don’t show any useful information right away. For example, see the following screenshot:

The page cannot be displayed because an internal server error has occurred

The page cannot be displayed because an internal server error has occurred

Here I am getting: The page cannot be displayed because an internal server error has occurred. There is no HTTP status code or substatus code listed on the error page. If you get such an error even when detailed errors are enabled, right-click anywhere in the browser window and select Inspect (or press F12).

Opening developer tools in web browser to reveal server errors

Opening developer tools in web browser to reveal server errors

This opens the developer tools in your browser window. Now, click the Console tab. The actual error thrown by the web server is displayed.

Viewing server errors using the Console tab of the web browser's developer tools

Viewing server errors using the Console tab of the web browser’s developer tools

To further understand the exact cause of 500 errors, enable Failed Request Tracing, as discussed in my previous post. Now, try to replicate the problem. If you can replicate it, open the newly generated XML log file in a web browser. The following screenshot shows the actual cause of a 500 – internal server error with a substatus code of 19 (HTTP 500.19 error):

Determining the cause of a 500 error using the Failed Request Tracing log file

Determining the cause of a 500 error using the Failed Request Tracing log file

Usually, substatus code 19 indicates that the configuration data is invalid. This could be due to some malformed or unidentified element in a server-level config file (ApplicationHost.config) or website-level config file (web.config). If you take a closer look at the ConfigExceptionInfo field of the log file, you will find the exact line number (6 in our case) in the web.config file that caused the exception. Now let’s take a look at the web.config file itself.

Viewing the problematic element in the web.config file

Viewing the problematic element in the web.config file

Here, you can see that the developer tried to add a mime type in the config file, but it was already defined in the server-level configuration file (i.e., ApplicationHost.config). Therefore, the Cannot add duplicate collection entry of type ‘mimeMap’ with unique key attribute ‘fileExtension’ set to ‘.mp4’ exception was returned. Furthermore, if there is some unidentified element, a syntax error, or even a typo in the web.config file, you will most likely get a similar error.

Resolving an IIS 500 – Internal server error

To resolve an IIS 500 – Internal server error, you could simply remove the line that is causing the exception. Alternatively, if you don’t want to remove this line for some reason, add the following code right above line 6 in web.config:

<remove fileExtension=".mp4" />

By doing this, you are essentially overriding the server-level element. In the end, your web.config file should look as shown below:

Overriding the server level mime element with web.config file

Overriding the server level mime element with web.config file

Now refresh the page, and the error should go away. This was just one example of resolving a 500.19 error. If you get a 500 error with a different substatus code, use the same approach to troubleshoot the problem.

Common 500.x substatus codes

The following table covers some of the most common HTTP 500 substatus codes, along with their probable causes and troubleshooting advice:

Subscribe to 4sysops newsletter!

Status Code Probable Cause Troubleshooting Advice
500.11 The application is shutting down on the web server The application pool is shutting down. You can wait for the worker process to finish the shutdown and then try again.
500.12 The application is busy restarting on the web server This is a temporary error and should go away automatically when you refresh the page. If the error persists, something is wrong with the web application itself.
500.13 The web server is too busy This error indicates that the number of incoming concurrent requests exceeded the number that your IIS application can process. This could be caused when the performance settings are not right. To troubleshoot such issues, a memory dump needs to be captured and analyzed using tools such as Debug Diagnostic.
500.15 Direct requests for Global.asax file are not allowed A direct request was made for the Global.asa or Global.asax file, which is not allowed by the web server
500.19 The configuration data is invalid We already covered how to fix this error above
500.21 The module not recognized This status code is caused by a partial installation of the IIS server, such as missing ISAPI modules. To fix this error, identify the missing IIS components and install them.

Once you troubleshoot the problem, don’t forget to disable Failed Request Tracing and revert the detailed errors to custom errors on your web server.

title author description ms.date ms.assetid msc.legacyurl msc.type

Troubleshooting IIS Performance Issues or Application Errors using LogParser

rick-anderson

This article describes the troubleshooting steps to identify performance issues by using Microsoft’s LogParser to analyze IIS logs.

12/18/2012

0a84b2a8-5ac6-41f4-b631-c1345b2ddf33

/learn/troubleshoot/performance-issues/troubleshooting-iis-performance-issues-or-application-errors-using-logparser

authoredcontent

Troubleshooting IIS Performance Issues or Application Errors using LogParser

by Benjamin Perkins

Tools and knowledge used in this Troubleshooter

  • Microsoft LogParser (https://www.microsoft.com/download/details.aspx?id=24659)
  • Command Prompt
  • A basic knowledge of IIS HTTP Status Codes is helpful (https://support.microsoft.com/kb/943891)
  • A basic knowledge of SQL queries is helpful

Overview

This troubleshooter will help you analyze IIS log files in an effort to determine the cause when an application that is hosted on IIS is failing or experiencing performance issues. Before you begin, it is important to note that all fields IIS can log are not enabled by default. For example, Bytes Sent and Bytes Received are not selected, but they are very useful when troubleshooting a performance problem. Therefore, the best time to include these additional fields is before you are experiencing system problems. So if you haven’t already done so, select these additional fields, they will help you find solutions when problems happen.

The following blog which discusses how to perform this on IIS 7+:

Modifying IIS 7 log data in Windows 2008

Scenario

As a Systems Administrator you begin to hear reports from users of your system hosted on IIS that the response is slow. There is some mention that web browsers simply time out or stop responding completely when they are accessing your website.

You jump into action and recycle the worker process; all appears to be working again, as normal.

However, you cannot accept that as a solution and need to know why this happened, but don’t know where to start. You have no details from the users, such as error codes, screen shots and worse, you have no performance data to compare what just happened to normal performance. In many cases, other new issues take you away from any serious root cause analysis.

Microsoft’s LogParser is a good tool that is quick and easy to use. In many situations, the tool will help you quickly get to a deeper understanding of what happened on the server and may help you identify problems. You can take the information you gather with LogParser and pass it along to your database team, your network team or to your developers for more analysis.

Data Collection

By default, IIS log files are located in the following directories:

  • IIS 7 and later: %SystemDrive%inetpublogsLogFiles
  • IIS 6 and earlier: %WinDir%System32LogFiles

In this troubleshooter, I will be using IIS 8. Open the IIS Manager and select Sites, as shown in Figure 1. This will show you the ID of each website hosted on your server. You will need this ID to determine which W3SVC* directory to analyze.

Screenshot of the I I S Manager window showing Sites in the main pane.
Figure 1: Getting the ID of your web site

Open Windows Explorer and navigate to the directory that contains the IIS log files of the website that experienced the performance problem. Figure 2 shows how that might look like.

Screenshot of Windows Explorer showing file locations.
Figure 2: IIS Log file location

IIS log files can be quite large; for example, in Figure 2, the log file u_ex12101858.log is nearly 100MB in size. Because these log files may be huge and contain hundreds of thousands of individual log file entries, manually looking through each of these files for an error is not a good approach, and returns few results for the time that you invest.

This is when LogParser becomes an indispensable tool in your troubleshooting arsenal.

Data Analysis

Your first step is to determine which log files may contain errors. For example, if customers were complaining about performance on the 3rd of June, 2012, the log file might be u_ex120603.log, where:

  • «12» is the abbreviated year for 2012
  • «06» refers to the sixth month (June)
  • «03» is the 3rd day of the month

Note: The above example assumes that IIS logging is configured to rotate log files on a daily basis, which is the default. If you have changed the settings for IIS to rotate log files on a different time interval, such as weekly or hourly, then the log files names would be different. For more information about the syntax for IIS log file names, see the IIS Log File Naming Syntax (https://support.microsoft.com/kb/242898) article.

[!NOTE]
By default, the date and time in IIS logs are stored using GMT; you will need to take this into account when you are determining which logs contain errors. That being said, you can adjust the dates/times by using LogParser’s TO_LOCALTIME() function, as illustrated in the following example:

[!NOTE]
[!code-sqlMain]

Once you have identified the IIS log files that contain errors, you should copy them to a location where they can be analyzed. This step is optional, but it is not recommended that you analyze your logs on your IIS server since your LogParser queries may take a long time to run, and if your log files are large then Log Parser may compete for system resources.

For example, you might copy your IIS logs to a folder on your personal computer where you have already copied the LogParser files, which is how I typically analyze my log files. Figure 3 shows an example of where I stored them to create this article.

Screenshot of Windows Explorer showing the location of the log parser executable.
Figure 3: IIS Logs files locally hosted for analysis using LogParser

After you have downloaded LogParser, you are ready to begin the analysis. The first query I run is shown in Figure 4. The results give you an overview of how IIS has been responding to the requests.

[!code-consoleMain]

Figure 4: LogParser Query (sc-status and sc-substatus)

The points of interest within the results are:

  • The ratio between 200 and 304 HTTP status codes (successful requests)
  • The number of 500 HTTP status codes (failed requests)

The significance for each of these status codes is explained below.

The Ratio Between HTTP 200 and 304 Status Codes (Analyzing Successful Requests)

The ratio between the 200 and 304 HTTP status codes is important because it shows how many requests are being retrieved from the clients’ cache instead of directly from the server. The results in Figure 4 show that there are 3,920,658 requests which resulted in an HTTP Status code of 200. This means that the requested file was served from the server each time. In contrast, there were 178,705 requests which resulted in a 304 HTTP status code. This means that the requested file was retrieved from the local cache. In other words, 95.5% of the requests are being handled from the server.

Caching can have some very positive impact on your system’s performance; see the details for both static and dynamic compression in the Configuring HTTP Compression in IIS 7 article.

HTTP 500 Status Codes (Analyzing Failed Requests)

HTTP 500 Status codes may indicate serious issues on your system. The level of impact that the root cause of an HTTP 500 error may have on your system can range from nothing to the crash of a worker process. Therefore, when you see these, you should execute the query shown in Figure 5 in order to find which requests resulted in a 500 HTTP Status code.

[!code-sqlMain]

Figure 5: LogParser Query (cs-uri-stem with a 500 sc-status)

These results show the path and the name of the file which, when requested, responded with an HTTP 500 Status code. This kind of information would be valuable to the development team. For example, the development team could look further into that specific code and search for code that executes without being contained in a try {...} catch {...} code block, or they are executing large data queries which need to be optimized.

Let’s take this example a step further and focus on the top contributor for HTTP 500 Status codes. It would be interesting to know when these errors occurred, because this information can be used to check if dependencies were having any problems at the same time.

[!code-sqlMain]

Figure 6: LogParser Query (cs-uri-stem with a 500 sc-status)

The subset of results in Figure 6 restricts the date range of the issue. This information can be passed along to network, database, operating system administrators and the development teams to check if anything else was happening at that same time. For example: Were there any additional problems between 08:00 and 09:59:59 GMT and between 14:00:00 and 14:59:59 GMT?

The next set of LogParser queries utilize the following fields, which may give better insight into performance problems:

Field Description Enabled by default
time-taken The length of time the action took, in milliseconds Yes
sc-bytes The number of bytes sent by the server No
cs-bytes The number of bytes the server received No

As mentioned before, take the time now to request the sc-bytes and cs-bytes fields be enabled or, if possible, enable them yourself. They provide some valuable insight into your system and its’ behavior. Take Figure 7, for example. You see that the average time is pretty good at a few hundred milliseconds. However, look at the maximum time-taken, that is way too much time.

[!code-consoleMain]

Figure 7: LogParser Query (MAX and AVG time-taken)

I know you are asking yourself already the next question that needs to be answered. Which request is taking so much time? Figure 8 shows the answer to that question. As you will notice, I have gone ahead and included the sc-bytes field in the LogParser query. Remember, sc-bytes represents the size of the file sent from the server back to the client.

[!code-sqlMain]

Figure 8: LogParser Query (MAX and AVG time-taken)

We would likely all agree that the time-taken for the requests exceeds a ‘normal’ response time. However, the size of the files is something which the administrator or developer would need to analyze to determine if the sizes are within an acceptable range.

The conclusion is that the GetDetailsView.aspx file has been throwing a number of 500 HTTP Status codes and has at some point taken a long time to complete, even though it was a relatively small file. You may want to look at the date and time when problems where occurring for this file, and examine the code in the file with any issues that occurred. (For example, the IIS logs contain a list of variables that were passed in the query string; you could check those values for bad data.)

The examples provided in figures 4 — 8 help gain an understanding around where the root cause of an issue may exist. It is likely, however, that this analysis has only rendered a better view of the situation which will lead to more questions and deeper analysis. If that’s the case you may want to create a representation of this data in a more presentable manner. The following section covers this in detail.

Reporting

Screenshots of a command window containing LogParser queries and their results may be fine during the analysis phase of a performance problem; however, if you need to go in front of managers or directors to explain what happened, it may not meet the mark.

[!NOTE]
In order to get charting to work via LogParser, you will need to install the Office Web Components. The following articles explain how to do this:

  • Advanced Log Parser Charts Part 3 — Missing Office Web Components for Charting
  • Charting with LogParser

Figure 9 shows the LogParser query to create a 3D pie chart containing the number of requests and their associated HTTP Status code. I removed status 200, as those are successful. What I am after here are the requests which are something other than OK.

[!code-sqlMain]

Figure 9: LogParser Query (Create a 3D pie chart)

The result of the query is illustrated in Figure 10. There are a number of additional parameters which you can pass to LogParser that affect the image. For example, legend, groupSize, config, etc… To get a complete list enter: LogParser -h -o:CHART for a list of all parameters. This command will also provide a list of the different chart types.

Diagram of a three-dimensional pie chart showing request status allocations.
Figure 10: LogParser 3D pie chart

Another useful chart is the ratio between cached and actual requests. Recall from the Data Analysis section where I discussed that an HTTP Status code of 200 means that the requested files are retrieved from the server however, a 304 is retrieved from the client. Figure 11 shows the LogParser query for the creation of this chart. Notice that I used the -values parameter.

[!code-sqlMain]

Figure 11: LogParser Query (Create a 3D pie chart)

Although the difference between HTTP Status code 200 and 304 are clearly visible, I thought it may add some value to include the number of hits for each. Figure 12 illustrates the output of the previous LogParser query.

Diagram of a three-dimensional pie chart showing the allocation of cache.
Figure 12: LogParser 3D pie chart

I think you are getting the picture now about how charting the IIS Logs using LogParser can help convey what is happening much better than a table of data. But before I stop, I want to show you one more example using the Column chart type. The LogParser query shown in Figure 13 produces a 3D Column chart showing the count of 500 HTTPS Status codes per hour.

[!code-sqlMain]

Figure 13: LogParser Query (Create a 3D column chart)

The resulting chart is illustrated in Figure 14.

Diagram of a three dimensional column chart showing the number of 500 errors per hour by date.
Figure 14: LogParser 3D column chart

Creating charts using Excel and CSV

At the beginning of this section I mentioned that the installation of the Office Web Component (OWC) is a requirement if you want to use the LogParser charting capabilities. In your organization, there may be restrictions that prohibit this or you simply might not want to install it. If either is the case, then consider exporting the LogParser query result to a CSV file and import it into Excel.

Figure 15 shows the LogParser query that extracts the HTTP Status codes for all request which are not 200 to a CSV file.

[!code-sqlMain]

Figure 15: LogParser Query (Create a CSV file for import into Excel)

Notice in Figure 15 that I used the -o parameter so that LogParser creates the output in CSV format.

To import the CSV file into Excel so that a chart can be created from it, open Excel, navigate to the DATA tab and select From Text. Figure 16 shows what this looks like.

Screenshot showing the Excel Data tab menu options.
Figure 16: Import CSV file created by LogParser into Excel

Select the status.csv file created by the LogParser query and navigate through the import wizard. Import the ‘comma’ delimited CSV file and you will end up with the Status in column A and the number of occurrences for each status in column B. This assumes you executed the LogParser query shown in Figure 15. Lastly, select all the data from column A and B, including the headers and choose the type of Pie chart to create. Figure 17, illustrates how this may look.

Screenshot showing the Excel Insert tab options. The data in columns A and B are selected.
Figure 17: Create a Pie chart using a CSV file

The end result is a Pie chart, Figure 18 that is similar to that shown previously in Figure 10. There are many options in regards to color, chart type, labels, etc. With a click of a button you can change the chart type from Pie to Bar or to Line. There are a lot of options for creating professional looking charts within Excel.

Screenshot of a three-dimensional pie chart showing request status.
Figure 18: A Pie chart using a CSV file similar to Figure 10

There are so many options and possibilities for analyzing and presenting the results of that analysis using LogParser. For some additional tips and examples, check out these articles written by Robert McMurray. There is also a very useful help file and many prewritten scripts provided within the installation package of LogParser. The next section will discuss this and other topics in more detail.

Help

When you install LogParser 2.2 onto your machine, it installs by default into the C:Program Files (x86)Log Parser 2.2 directory. Navigate to that location and review the SamplesQueries and SamplesScripts directories for an abundant supply of prewritten code that will get you moving fast.

You will also realize a great benefit by reading through the contents within the LogParser.chm file.

Reducing the size of or splitting IIS log files

You may encounter a situation where the IIS log file is too big for LogParser to query. This is most likely on a 32-bit machine, but can happen on a 64-bit machine too. Nonetheless, if you experience ‘out of memory’ errors when running a LogParser query, consider executing the command shown in Figure 19. The query extracts some essential fields from a large IIS log file and places them into another, which results in a smaller log file.

[!code-consoleMain]

Figure 19: Reducing the size of an IIS log file (by removing fields)

In this example, I realized a file size reduction of about 45%. In many cases this may be enough, in others maybe not. It depends on the size of the original log file. If you find that you still need to reduce the size of the IIS log file, consider adding a date time constraint to the LogParser query as shown in Figure 20.

[!code-sqlMain]

Figure 20: Further reducing the size of an IIS log file by adding a WHERE clause

This is a valuable technique for reducing the file size, but it is also useful to remove unwanted entries from the IIS Log. For example, when beginning to troubleshoot an issue you realize that time-take, sc-bytes and cs-bytes were not being logged. You enabled them in IIS and want the query to only analyze those entries with the recently enabled fields. Use the where statement to extract the data from the IIS log file from the time in which those fields have been enabled. This is important when you use the AVG, MIN and MAX aggregates.

Conclusion

LogParser is a small but powerful tool to analyze a number of different system log types. This article focused on queries applicable to IIS Logs. When performance problems or errors are experienced in your IIS environment, it is sometimes difficult to know where to start.

LogParser can be used as a starting point, because a system administrator who has some SQL skills can quickly build some very sophisticated LogParser queries. These queries can be used to further the root cause analysis of the problem.

Useful Links

Here are the links which are referred to in this article, plus a few links with additional information.

  • Microsoft LogParser: http://www.bing.com/search?q=logparser or https://www.microsoft.com/download/details.aspx?id=24659
  • The HTTP status codes in IIS 7.0, IIS 7.5, and IIS 8.0
  • Modifying IIS 7 log data in Windows 2008
  • Modifying IIS 6 log data in Windows 2003
  • Configuring HTTP Compression in IIS 7
  • Charting with LogParser using OWC
  • Robert McMurray’s Blogs on LogParser
  • Microsoft Log Parser Toolkit: A Complete Toolkit for Microsoft’s Undocumented Log Analysis Tool

Over the years, Microsoft IIS has grown to be an exceptionally flexible product, supporting numerous technologies, products, extensions, and configuration options. IIS can do almost anything, from servicing simple static pages to being a fully blown, enterprise-grade reverse proxy server. Like any complex product, though, IIS requires troubleshooting on occasion. Here we’ll look at some of the most common challenges that web developers and administrators face when deploying and developing applications for IIS and how to troubleshoot them properly.

Runtime Errors and Exceptions

The most common issues customers encounter when deploying or developing for IIS are runtime errors and exceptions, which include various errors from the 40x and 50x families of HTTP errors. These errors include the common 404 and less-common 400 errors, as well as the dreaded 500 internal server error.

The appearance of these errors varies depending on the IIS server’s configuration. The HTTP 500 error, which is typically an application or pipeline error where something failed before the application sent any response, could manifest itself as a simple error in the browser, such as the examples shown in Figure 1.

Figure 1: HTTP 500 Internal Server Error Examples

Figure 1: HTTP 500 Internal Server Error Examples

However, if the error occurs in a managed code .NET application, the error might look like that shown in Figure 2.

Figure 2: IIS Server Configuration Error

Figure 2: IIS Server Configuration Error

The first step in figuring out such errors is a differential diagnosis. This means that we need to deduce from user reports that the site hangs are actually IIS worker process (w3wp.exe) crashes (which are what happens when a web application experiences a major error) or possibly something else, such as a configuration problem of some kind. We can find this information from multiple sources:

  • IIS logs
  • by disabling custom errors to display detailed error pages
  • failed request tracing
  • Windows Application Event Logs

Examining the IIS logs is a good first step, as the logs are easy to read and would confirm whether or not the error is really a 500 error. If it is a 500 error, the log line would show the HTTP status code to be 500 0 0, as in Figure 3, instead of the expected 200 code.

Figure 3: HTTP 500 Error as Shown in IIS Log

Figure 3: HTTP 500 Error as Shown in IIS Log

The next step is to look for more details about the error. It’s not uncommon for administrators who see this error to assume that it portends the worst. The error seems to suggest there’s a problem with the code, and many system administrators are not trained to read or debug code. In reality, this type of error can be really simple to understand once you realize that the seemingly meaningless XML tags are not the actual error but rather a message telling you that the default configuration prevents IIS from actually showing you what’s wrong. (Why so? Because we don’t want strangers who visit the site to get details about your code!)

To see what’s really going on, we need to configure the server to be more informative. This is done by adding a section to the site’s web.config file. The steps are:

  1. Open the site’s web.config file with an editor of your choice.
  2. Inside the system.web section of the file, add the line . For example:

    
    
    

Note: The reason we use RemoteOnly here is to display the error only on your local server and not to users trying to visit the site. If you want the error to be displayed publicly, or if you are setting the configuration on a Windows Azure Web Sites server (to which you don’t have direct access), you would set the mode to Off.

Now, if you connect to the site again, the error page will show more information, which could potentially solve the riddle right then and there. For example, the error page shown in Figure 4 indicates that the code is trying to populate a variable that wasn’t declared.

Figure 4: IIS Server Compilation Error

Figure 4: IIS Server Compilation Error

An alternative way to view this error, if you prefer, is to inspect the Application event log on the system. When an application error such as the one shown in Figure 4 occurs, it will be logged as coming from ASP.NET. In such a situation, the event details would contain the same information, as shown in Figure 5. (The code filename, line, and error details are highlighted in yellow.)

Figure 5: Viewing Error Details in Application Event Log

Figure 5: Viewing Error Details in Application Event Log

Another common variation of an internal server error is error number 500.19. This error is also one you might run into when you’re using Azure Web Sites and developing advanced applications. The error looks like the page shown in Figure 6.

Figure 6: IIS Invalid Configuration Error

Figure 6: IIS Invalid Configuration Error

Error 500.19 is actually an entire family of errors pertaining to problems in the website’s configuration that’s specified in web.config. Figure 6 shows a permission problem, which could happen if the access control over the website’s folder is not set correctly and IIS cannot read the configuration.

Another variation of this is error 0x80070021, which happens when a section you are trying to configure in a site’s web.config conflicts with a setting set in the higher-level ApplicationHost.config file. For example, on an IIS server, the MIME types for content compression are set by default to disallow a site-level web.config configuration. If you try to add a configuration section to web.config without adjusting the inheritance settings first, you would receive this error.

Yet another variation of error 500.19 is 0x80070032, which happens when a section is missing configuration information. It’s not always easy to figure out what you did wrong, especially if your configuration is complex or if you’re trying to configure something that doesn’t have a lot of examples in the documentation, so for this error, an incremental approach is typically useful.

Although it would be impossible to cover every conceivable variation of the 500 error, the key lesson here is to get IIS to show you the complete details. Once you have those, the accompanying text often will provide all the information you need. If you need more information, you can search for the error code or keywords online and in that way find enough information to pinpoint the actual problem. For other errors, the error codes are usually more direct—see this Microsoft article for a list of the most common codes and additional information about them. Also see this list of Win32 errors, which can also help you learn more about many issues.

Crash and Hang Problems

A process crash happens when there is an error in a web application, which causes an exception, leading to termination of the IIS worker process (w3wp.exe). Unlike a regular application crash, where the user can easily see the application disappearing, with a web-based app there’s no such disappearance visible to the naked eye, so things can sometimes get murky. Sometimes, the user might get a Service Unavailable message in the browser (which might be totally unclear and confusing to an average user, but at least it’s something to start with). Other times, IIS will start a new w3wp.exe process to service the request. Although the second option seems desirable, as the user doesn’t run into errors, in reality, it could be almost as bad as the Service Unavailable error, because unbeknownst to the administrator or application developer, the application might be crashing all the time, providing a slow and unreliable service.

The good news is that the server will log events even if the user doesn’t experience a problem, which helps the administrator or developer catch such errors early. Typically crash-related events would be event ID 5009, which indicate a worker-process crash, or event IDs 5010 and 5011, which indicate that the process-activation service could not get a reply from a worker process. When any of these errors occur, they are often accompanied by an event ID 1000, which is for an application crash.

Having a process crash occasionally doesn’t always warrant a full investigation. No code is perfect, and if you run into a crash a few times a month, it’s usually not the end of the world. IIS recovers and starts a new w3wp.exe process upon the next request that comes in for the application. Naturally, though, if the crash causes data loss, or if it’s frequent enough to cause turmoil within your user base, then the investigation typically involves getting a crash dump, which contains a snapshot of the process when the exception occurs.

Examining a crash dump can be a challenge, as the connection between what’s in the dump and the root cause isn’t always evident. If you are the application developer, an alternative to this is to write your application code to include trace information that might make it possible to troubleshoot directly, or at least help in the process. This would involve adding to each function in your code a call to log actions and key variables into a text file (typically through a dedicated logging function). For example, when you run a loop, you can have the function log a line for each iteration, like this:

fTraceLog("Starting going through aRequestItems array at " & now)
For I = 0 to ubound(aRequestItems)
     fTraceLog("Request Item " & I & " contains " & aRequestItems(i))
     sRequestAction=http:// & cstr(aRequestItems(i)) & "/SetRecords.asp" & iJIDNumber
next
fTraceLog("Finished going through aRequestItems array at " & now)

With this code, if there is a problem with the loop, the last item in the trace could potentially reveal what it is. Keep in mind, though, that this sort of tracing could lead to a high strain on the server, so it should normally be turned off until an investigation is required.

The tricky part about crash dumps is that they need analysis, which is traditionally seen as a developer-level task. Fortunately there are some advanced tools that make crash-dump analysis more accessible for non-developers. The free Debug Diagnostic Tool (DebugDiag) contains some pretty powerful automatic analysis tools, which can shed light on a lot of issues without requiring you to look at a single line of code.

To use DebugDiag, you need to create a rule, which will instruct the debugger to detect when IIS crashes and collect the crash dump. To do so, follow these steps:

  1. Launch DebugDiag from the Start menu or Start screen.
  2. Click Crash, and then click Next.
  3. Select the desired Target Type, then click Next.
  4. In the Advanced Configuration (Optional) dialog box, click Next.
  5. In the Select Dump Location And Rule Name (Optional) dialog box, click Next.
  6. Click to select the Activate the rule now check box, then click Finish.

After you have set up the rule, you need to reproduce the issue, if you can, or wait for IIS to crash again. Once that happens, the rule will cause a creation of a dump, which you can now analyze. To perform the analysis, follow these steps:

  1. Run the DebugDiag 2.0 analysis tool from your Start menu or Start screen. You’ll see the DebugDiag Analysis screen, as shown in Figure 7.
  2. Click Add Data Files to tell the tool which file to analyze.
  3. Select which Analysis Rules you want to run (we are looking into a crash, so you would typically check the Crash/Hang Analyzers rule).
  4. Click Start Analysis to analyze the dumps.

Figure 7: DebugDiag Analysis Screen

Figure 7: DebugDiag Analysis Screen

Once the analysis is finished, DebugDiag generates an HTML report and opens it in your browser automatically. The report lists all the problems found and also provides suggestions for solving them. Based on the problem’s severity, the issues found are categorized in three types: Error, Warning, and Information.

Depending on the issue, the report could be a simple read, but it could also leave you more confused about the problem. As with any other type of troubleshooting, you’ll need to carefully read the data in the onscreen report to gain a better understanding of the problem. Used properly, search engines can also be helpful. For example, you might see this message displayed in the report:

The application domain is restarting because of reason:- A change was made to the Bin folder or to files in it

Too many application domain restarts are not good for an application. Please refer to the article

Lost session variables and appdomain recycles for more details on this issue.

As you can see, this message suggests what the problem is and even provides a link to further reading. Here’s another useful message:

The requests start getting queued if all the threads available to process the request are busy. Look at the callstacks of the threads which are processing the request to see why they are running for a long time. Also, look at the ASP.NET Request Queue Report to see the ASP.NET Threadpool settings and the runtime for which the requests are getting queued.

There’s More to Learn

Naturally, we cannot cover the entire range of possible issues with IIS here. However, as you use DebugDiag more, you will find that it’s exceptionally intuitive and helpful in IIS debugging. For additional information about debugging IIS issues, also see the following articles from Microsoft’s knowledgebase can guide you further. These articles also discuss scenarios other than a simple crash:

  • How to use the Debug Diagnostics tool to troubleshoot an IIS process that stops unexpectedly
  • How to use the Debug Diagnostics tool to troubleshoot a process that has stopped responding in IIS
  • How to use the Debug Diagnostics Tool to troubleshoot high CPU usage by a process in IIS
  • How to use the IIS Debug Diagnostics tool to troubleshoot a memory leak in an IIS process

About the Authors

Erez Benari is a senior web technology professional with more than 20 years of experience. During his career, Benari worked for some of the largest companies in the world and has an extensive background in business, economics, communications, and education. He is a resident of Washington, where he works for Microsoft as part of Windows Azure. In his role, Erez is a program manager for IIS, Microsoft’s web server platform, as well as Windows Azure Web Sites. Benari is also a journalist, a published author, and a professional stand-up comedian.

Richard Marr is a senior Escalation engineer with Microsoft support. He has worked for Microsoft since 2000. During his career, he has supported Microsoft Access, IIS, and ASP.NET and now works with Windows Azure Web Sites. Richard is a graduate of Mount Saint Vincent University in Canada and holds a Bachelor of Business Administration. He lives with his family in Texas.

Wei Zhao is a Shanghai-based Escalation Engineer for Microsoft. In his role, he helps Microsoft’s customers design, develop, deploy, and operate enterprise solutions using IIS, ASP.NET, and Windows Communication Foundation (WCF). Most recently, Zhao is also focusing on Windows Azure Web Sites.

  • Remove From My Forums
  • Question

  • Hi All,

    I’m having SCCM 2012 R2 SP1 standalone primary site.

    MP is working fine (200 status in MPControl.log) but I can see lots of ‘500’ errors in IIS logs, what  does it imply? how do i get rid out of this? 

    IIS Logs from MP server:

    2015-10-11 08:41:33 10.72.160.23 CCM_POST /ccm_system/request — 80 — 10.17.95.59 ccmhttp —
    500 19 5 0
    2015-10-11 08:41:39 10.72.160.23 CCM_POST /ccm_system/request — 80 — 10.73.160.21 SMS+CCM+5.0+TS —
    500 19 5 0
    2015-10-11 08:41:39 10.72.160.23 CCM_POST /ccm_system/request — 80 — 10.73.160.21 SMS+CCM+5.0+TS —
    500 19 5 15
    2015-10-11 08:41:39 10.72.160.23 CCM_POST /ccm_system/request — 80 — 10.73.160.21 SMS+CCM+5.0+TS —
    500 19 5 0
    2015-10-11 08:41:42 10.72.160.23 CCM_POST /ccm_system/request — 80 — 10.250.52.177 ccmhttp —
    500 19 5 0
    2015-10-11 08:41:42 10.72.160.23 CCM_POST /ccm_system/request — 80 — 10.73.160.21 SMS+CCM+5.0+TS —
    500 19 5 15
    2015-10-11 08:41:42 10.72.160.23 CCM_POST /ccm_system/request — 80 — 10.73.160.21 SMS+CCM+5.0+TS —
    500 19 5 0
    2015-10-11 08:41:42 10.72.160.23 CCM_POST /ccm_system/request — 80 — 10.73.160.21 SMS+CCM+5.0+TS —
    500 19 5 15

    Thanks in advance

Answers

  • According to the following table: Error 500 19 is «Configuration data is invalid»

    https://support.microsoft.com/en-us/kb/943891

    Have you checked any of the MP_*.log related files for your Management Point for errors?

    Have you gone through the configuration of your Management Point and made sure that all the prerequisites are correctly installed? If you have the option, perform the following:

    1. Uninstall the Management Point role.

    2. Run the following tool to make sure that all prerequisites are installed: https://gallery.technet.microsoft.com/ConfigMgr-2012-R2-e52919cd

    3. Re-install the Management Point role and make sure that you check the box for configuring IIS.


    Nickolaj Andersen | www.scconfigmgr.com |
    @NickolajA

    • Marked as answer by

      Sunday, October 11, 2015 9:20 AM

If you’ve  ever had to troubleshoot issues with IIS you’ll known that you are often drawn to looking at IIS Logs.    This post is about a script that I modified to search IIS logs for specific errors.

To begin with I found this article on StackOverFlow that got me started on this path.

To begin with we need to get the webadministration module so we can get the name of the website we want to get the log file for:

Import-Module WebAdministration

$site = Get-Item IIS:Sites$website
$id = $site.id
$logdir = "$($site.logfile.directory)w3svc$id"

Now that we have the  The $logdir (log directory) we can now put the rest of the file name together by getting the date:

$File = "$logdiru_ex$(((get-date).adddays(-$days)).ToString("yyMMdd")).log"
s

Assuming you are using a logfile per day the name of the log file is:

u_ex(yyMMdd)  which should be something similar to this: u_ex170824.log

Now that we have our log file we need to strip off unnecessary lines.  Specifically the First three lines that start with #S, #D, or #V which ends up being the Sofware, Version and Date items at the top of the log.

Then we’ll need to Build the columns based on the #fields value in the Log. That way each field in the results can be arranged into columns so we can sort our data based on what the item in the field is.

The additional column we’ll add is the name of the log file.

$Log = Get-Content $File | where {$_ -notLike "#[D,S-V]*" }

$Columns = (($Log[0].TrimEnd()) -replace "#Fields: ", "" -replace "-","" -replace "(","" -replace ")","").Split(" ")

$Columns += 'LogFile'

$Count = $Columns.Length

Now that we have the column titles now it’s time to filter out the log and only get the lines that have the value we want.  In my case I was searching for the Error code of 500.

$Rows = $Log | where {$_ -like "*$errorType 0 0*"}

Now that we have all the data we want in the row’s variable we can now construct a table of Columns and rows.

$IISLog = New-Object System.Data.DataTable "IISLog"

foreach ($Column in $Columns) {
$NewColumn = New-Object System.Data.DataColumn $Column, ([string])
$IISLog.Columns.Add($NewColumn)
}
# Loop Through each Row and add the Rows.
foreach ($Row in $Rows) {
$Row = $Row.Split(" ")
$AddRow = $IISLog.newrow()
for($i=0;$i -lt $Count; $i++) {
$ColumnName = $Columns[$i]
if($ColumnName -eq 'LogFile')
{$AddRow.$ColumnName = $file }
else {$AddRow.$ColumnName = $Row[$i]}
}
$IISLog.Rows.Add($AddRow)
}

$IISLog

Full function is below:

  function get-ErrorLogs
  {
  param($website = 'myWebSite', $errorType = '500',[int] $days =0)

    Import-Module WebAdministration

    $site = Get-Item IIS:Sites$website
    $id = $site.id
    $logdir = "$($site.logfile.directory)w3svc$id"

    $File = "$logdiru_ex$(((get-date).adddays(-$days)).ToString("yyMMdd")).log"
    $Log = Get-Content $File | where {$_ -notLike "#[D,S-V]*" }
    $Columns = (($Log[0].TrimEnd()) -replace "#Fields: ", "" -replace "-","" -replace "(","" -replace ")","").Split(" ")
    $Columns += 'LogFile'
    $Count = $Columns.Length
    $Rows = $Log | where {$_ -like "*$errorType 0 0*"}
    $IISLog = New-Object System.Data.DataTable "IISLog"
    foreach ($Column in $Columns) {
      $NewColumn = New-Object System.Data.DataColumn $Column, ([string])
      $IISLog.Columns.Add($NewColumn)
    }
    foreach ($Row in $Rows) {
      $Row = $Row.Split(" ")
      $AddRow = $IISLog.newrow()
      for($i=0;$i -lt $Count; $i++) {
        $ColumnName = $Columns[$i]
        if($ColumnName -eq 'LogFile')
        {$AddRow.$ColumnName = $file }
        else {$AddRow.$ColumnName = $Row[$i]}
      }
      $IISLog.Rows.Add($AddRow)
      }

    $IISLog
  }

Now that I have this in a full function I can just call it like this:

get-ErrorLogs -website “Website2” -errorType 500 -days 4

And get results similar to this:

500


I hope this helps someone
Until then keep Scripting
Thom


Понравилась статья? Поделить с друзьями:
  • Illegal target for annotation python ошибка
  • Illegal string offset error
  • Illegal storage access critical error как исправить
  • Iis error 502
  • Illegal start of type java ошибка