Tuesday, May 25, 2010

SELECT * FROM Log... with the cool tool that’s been around for years, Log Parser!

Jonathan Allen - Using LogParser - part 1

“I have mentioned LogParser before on my blog and have decided to create a series of walk-through style articles to show someone new to LogParser what it can do and how to use it. It is appropriate to all sorts of job roles in IT, whether you are a System Administrator or a SQL DBA.

LogParser, and all of its documentation, can be downloaded from http://www.microsoft.com/downloads/details.aspx?FamilyID=890cd06b-abf8-4c25-91b2-f8d975cf8c07&displaylang=en and its a very simple installation process.

For the scripts in this series I will work with these files: Person_Address.csv and Sales_SalesOrderDetail.tsv, these are available for download from here as individual zip files or in Everything.zip or you can create your own from the AdventureWorks database by running the script LP_SourceData.sql(also in the zip file) and saving the results from SQL Server Management Studio to C:\LP on your own computer.

Downloaded? Installed? Good, Lets go. …

OK, that's almost it for this instalment but I'll leave you with the syntax to let you open up some files and see the contents. This is where its at its most simple, you can view data from a file by starting LogParser and typing LOGPARSER "SELECT * FROM C:\LP\person_address.csv" and their contents of the test.csv file will be listed to you.

In the next part of this series we will review some different output formats and how to control what data is selected. …

image …”

Log Parser is one of those magical utilities that few seem to know about, but does some awesome things. The important thing is to remember “Log” doesn’t have to mean IIS Log. Think Application Log, Text Log, stuff logged to a file, etc, etc.

Now imagine you have a large log file. Wouldn’t it be cool to easily “query” it, say with a SQL like statement? No importing into a database, etc, we’re talking “querying” the actual file.

We’re talking Log Parser!  :)

 

Related Past Post XRef:
The Unofficial Log Parser Support Site
Download details: Log Parser 2.2

IIS Diagnostics Toolkit (January 2006)
SQL Server 2000 Report Pack for IIS Logs

No comments: