Often, especially in a Web Farm, we have more than a Web Server (with IIS) and we need to analyze its logs in a quicker and simpler way than
importing them manually in an Excel Sheet.
The solution comes from Microsoft (as usual) with a tool made to manipulate IIS Logs: Log Parser (version 2.2 at the time I’m writing).
Log Parser is a command-line tool with multi-source / multi-target log parsers; the flexibility of the tool has to be paid with a complex syntax.
In my daily job I had the need of importing IIS Logs into a SQLServer Db for analyzing it: here’s the command line I used to accomplish the task.
Naturally, the command HAS TO BE customized with:
- File Name of the Log File from the IIS Server [ex20100726.log in my example]
- Database coordinates (Server Name, Db Name,Login, Password) [DB01, Logs, DbUser, DbPassword in my example]
- Table [IISLogs in my case]
Be aware of the parameter createTable:ON that will create a table with the schema needed to import the Log.
In case you need to import Logs with different columns (e.g. you needed to have the Time Taken field later than
production day), as my personal suggestion, do it in different tables.
In the next part of the micro-series, I’ll explain how to do a simple script to import (and eventually delete) multiple files thru