Log Parser is a great tool for analyzing many types of text data. It is a free downloadable tool from Microsoft it installs a command line version and a COM component. It is a powerful tool for using the SQL language to query most types of fixed or delimited text data.
I recommend this article as an excellent place to begin learning to use log parser. It was written by the author of Log Parser, Gabriele Giuseppini and is a good overview. After reading it a great next step is to download Log Parser 2.2 here install it and take a look at the compiled help file.
The help file for the product is pretty good. The first two sections have enough information to get a good start. General use of Log Parser is covered there and other places so I will only give a brief overview here.
I believe most people probably start using log parser directly on the command line.
Example: c:LogParserlogparser.exe “SELECT Top 10 cs-uri-stem, Count(*) FROM D:Logsex081110.log Group By cs-uri-stem Order by cs-uri-stem desc” –i:w3c
Another good way to experiment with Log Parser is to use a batch file and a SQL file.
Example – Top 10 web Pages:
This batch file prompts for the input, output, and sql query files and executes Log Parser to query a w3c log file. Log Parser allows the use of variables inside the SQL query. The example below inserts the values for the input and output files entered at the prompts into the query.
Set /p INPUTFILE=Enter input file Path:
Set /p OUTPUTFILE=Enter output file Path:
Set /p SQLFILE=Enter SQL file Path:
"C:Program FilesLog Parser 2.2LogParser.exe" file:%SQLFILE%?infile=%INPUTFILE%+outfile=%OUTPUTFILE% -i:w3c -o:w3c
Log Parser SQL File
This SQL file gets the top ten pages by hits from a w3c log file.
Select Top 10 cs-uri-stem As Page, Count(*) As Hits
Group By Page
Order By Hits DESC
These are basic examples of how Log Parser works. Next time I will talk about using Log Parser from PowerShell.