Monday, March 5, 2007

IIS Log Parser is a deadly tool

A lot of microsoft products are genuienly good but never get noticed for some reason or another...IIS LogParser is one of those !!!

Its this handy little tool which analyses logs and gives neat results...

I used it to find the cause of 404 errors on my server

Here is the handy dandy script I wrote....

SELECT cs-uri-stem, COUNT(*) as Errors, sc-status INTO C:\IISLogs\GreaterThen400.csv FROM C:\IISLogs\ex*.log WHERE sc-status >=400 GROUP by cs-uri-stem, sc-status

Then I parsed to the LogParser directory on my machine and ran the following command...

LogParser -i:W3C file:C:\IISLogs\query.sql -o:csv

And got the following results -

Statistics:
-----------
Elements processed: 543410
Elements output: 643
Execution time: 1.97 seconds


Explaination of the command



-i:W3C - input is a W3C file
-o:csv - output is a csv file
file:query.sql = which file has my SQL query in it...you can run it directly as well if you really wanted

Then, I thought some more and volah...created a Bat file to get me the results of all the questions I always wanted to know and never could !! [;)]

Open a notepad - paste the following and save it as a "createAnalyzeAndProve.bat" or any other name that facinates you !!

"C:\Program Files\Log Parser 2.2\LogParser" -i:W3C file:C:\IISLogs\query.sql -o:csv

"C:\Program Files\Log Parser 2.2\LogParser" -i:W3C file:C:\IISLogs\301.sql -o:csv


Valery's Blog



Here is someone who used LogParser to sort through their event viewing problems...More power to them

IIS for event logs

So Long to all those fancy softwares who promised a lot and never delivered !!!

1 comment:

Unknown said...

Well, I don't understand whatever you have written here, but I am a strong supporter of Microsoft products. I don't know how people abuse Microsoft left and right and at the same time run XP and office on their computers..damn hypocrites...lol!!