Using LogParser 2.2 to Parse IIS Logs and Other Logs
page 3 of 13
by Sudeep G
Feedback
Average Rating: 
Views (Total / Last 10 Days): 93668/ 312

Scenario 1: Common types of outputs

This one is very common and I probably see this almost every day. Your Web site or web application is performing very slowly and you want to know which pages are taking the longest amount of time to be served. You can run the following query from the log parser command prompt.

Listing 2

LogParser "SELECT cs-uri-stem, time-taken FROM ex080620.log ORDER BY time-taken 
DESC" -i:IISW3C -q:ON

Now, let us say you want to view the Top 5 from this, you can then use:

Listing 3

LogParser "SELECT TOP 5 cs-uri-stem, time-taken INTO MyChart.GIF FROM ex080620.log 
ORDER BY time-taken DESC" -i:IISW3C -charttype:Bar3d -view:ON

Figure 1

OR create an exploded PIE:

Listing 4

LogParser "SELECT TOP 5 cs-uri-stem, time-taken INTO MyChart.GIF FROM ex080620.log 
ORDER BY time-taken DESC" -i:IISW3C -charttype:PieExploded3d -view:ON

Figure 2

Listing 5: Finding the average time taken for web pages

LogParser -i:IISW3C "SELECT cs-uri-stem, AVG(time-taken) As AvgTime FROM 
ex080620.log GROUP BY cs-uri-stem" -q:ON -0:DataGrid

Listing 6: Finding the number of hits to your web pages

LogParser -i:IISW3C "SELECT cs-uri-stem, COUNT(*) As Hits FROM ex080620.log GROUP 
BY cs-uri-stem" -q:ON –o:DataGrid

Listing 7: Finding the number of hits to web pages in a 3d Bar graph

LogParser -i:IISW3C "SELECT cs-uri-stem, COUNT(*) As Hits INTO Hits.Gif FROM 
ex080620.log GROUP BY cs-uri-stem" -chartType:Bar3D -ChartTitle "WebPage Hits" 
-view:ON

Figure 3

 

Listing 8: Finding the number of hits to a specific web page

LogParser -i:IISW3C "SELECT cs-uri-stem, COUNT(*) As Hits FROM ex080620.log WHERE 
EXTRACT_FILENAME(cs-uri-stem) = 'AdvancedSearch.aspx' GROUP BY cs-uri-stem" 
-o:DataGrid

Create a text file and name it as "HitsToPage.bat" and paste the following line in it. Then save it.

Listing 9: Scripting the above with batch file

LogParser -i:IISW3C "SELECT cs-uri-stem, COUNT(*) As Hits FROM %1 WHERE 
EXTRACT_FILENAME(cs-uri-stem) = '%2' GROUP BY cs-uri-stem" -o:DataGrid

Run it as example: HitsToPage C:\Logs\ex080620.log AdvancedSearch.aspx.

Listing 10: Finding what is the Hit rate for various types of content like GIF, HTML, etc.

LogParser -i:IISW3C "SELECT EXTRACT_EXTENSION(cs-uri-stem) AS PageType, COUNT(*) 
AS Hits INTO PageDistribution.GIF FROM ex080620.log GROUP BY PageType ORDER BY 
Hits DESC" -chartType:PieExploded3d -view:ON

Figure 4

Listing 11: Finding what type of content takes most of the bandwidth on the IIS web server

NOTE: You must enable the field sc-bytes in IIS to get this.

LogParser -i:IISW3C "SELECT EXTRACT_EXTENSION(cs-uri-stem) AS PageType, 
SUM(sc-bytes) AS Bytes INTO TrafficDistribution.GIF FROM ex080620.log GROUP BY 
PageType ORDER BY Bytes DESC" -chartType:PieExploded3d -view:ON

View Entire Article

User Comments

No comments posted yet.

Product Spotlight
Product Spotlight 





Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2020 ASPAlliance.com  |  Page Processed at 2020-07-04 9:47:26 PM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search