Sunday, June 2, 2013

How to use Log parser with IIS logs

Download and install log parser 2.2 from below link:
Make sure you read all the software usage policies and agreements before you use any software.
Once you install the software, you will find the exe and related files at- C:\Program Files\Log Parser 2.2
Copy the files and put it in a folder of your convenience.
Copy the log file folder from C:\inetpub\logs\LogFiles\
The folder name would be something like W3SVC1612407519 in which ‘1612407519’ will be ID of the web application from IIS which you can find out as shown below:

The log files in the folder will be text files. Screenshot below:

So now that we have the folder, copy the bat files to the same folder in which we have all the files and log file folder.
Click on edit you will see a query like:
LogParser.exe -i:IISW3C "SELECT TOP 1000 cs-uri-stem as URIStem, COUNT(*) as Hits INTO C:\Users\libin.makkalikkal\Desktop\TestLogparser\URLHitDetails.csv FROM C:\Users\libin.makkalikkal\Desktop\TestLogparser\W3SVC1612407519\* WHERE URIStem Is Not Null AND date>'2013-01-15' GROUP BY URIStem" -e 1
The file path in green is the path of csv file into which we are writing the output. The file path in red is the path where IIS logs are located. Please change the date highlighted in blue to the date starting from which we require data. Edit the bat file with new file locations and date, save and run it.

You will see the ouput csv file created in the folder with the query results.

You can use the query to get information from a specific time period if used as below:

    COUNT(*) AS Hits FROM c:\inetpub\logs\LogFiles\W3SVC1\*
WHERE date>'2010-03-01' and date<'2010-04-01' Group By Hour

Some useful links to create and edit the log parser queries:

No comments:

Post a Comment