Archive

Archive for September, 2010

Using the DATAGRID output option in LogParser to see error 500 IIS issues

September 17th, 2010 1 comment

I love Logparser but sometimes I don’t want large amounts of data in a command prompt. And you may not want to drop it into a csv file either, you just want a nice readable output in front of your face immediately. So I like to use the DATAGRID output option which gives me a nice neat GUI output for these situations. Here is an example I used this morning to pull all the IIS error 500 messages in an IIS W3C formated log file:

logparser "SELECT date, time, cs-method, s-ip, s-port, cs-username, c-ip, cs-host, time-taken, cs-uri-stem, cs-uri-query FROM C:\Logs\ex100917.log WHERE sc-status = 500" -rtp:-1 -i:iisw3c -o:datagrid

and here’s one to see the average time taken on every page on your site. This is great to pinpoint those pages with high load times that you can possible optimize. In this example, I want to include every page in my stats except those that threw an error 500:

logparser -i:IISW3C "SELECT cs-uri-stem, AVG(time-taken) As AvgTimeTaken FROM C:\Logs\ex100917.log WHERE sc-status <> 500 GROUP BY cs-uri-stem ORDER BY AvgTimeTaken DESC" -q:ON -o:datagrid

Now we know how pages normally perform. Now let’s compare that to the pages that did have error 500s. I also want to add a column for the total number of error 500s on each page. So a slight modification in the query:

logparser -i:IISW3C "SELECT cs-uri-stem, Count(*) AS Error500Hits, AVG(time-taken) As AvgTimeTaken FROM C:\Logs\ex100917.log WHERE sc-status = 500 GROUP BY cs-uri-stem ORDER BY AvgTimeTaken DESC" -q:ON -o:datagrid

All the data that is output using datagrid exports to an Excel spreadsheet nicely. Just right click, Select All and then copy and paste into your .xlsx spreadsheet.

Categories: IIS Tags: ,