Previously, I wrote about setting up IIS logging to allow for better performance analysis using Microsoft Log Parser. Now, that we’re collecting the necessary data it’s time to start querying the logs and see what we can find as well as prepare stats that can be viewed in a browser. Since I’m fairly new to Log Parser and considering it has been rather widely covered I’ve decided to touch on making reports available from the server.
I’m interested in setting up an automated process where log file stats get generated to html files and published from the server. Fortunately, Log Parser supports just such a thing using a template mechanism though it seems to be only lightly documented. Basically, you can create a template HTML file with specific tags which Log Parser uses in a mail merge-like fashion. Here is an example template and its resulting output/screenshot:
<head><title>most hit urls</title>
<h1>most hit urls</h1>
To use this template with Log Parser the command line looks like this:
"C:\Program Files\Log Parser 2.2\LogParser.exe" "SELECT TOP 10 cs-uri-stem as Url,
COUNT(cs-uri-stem) AS Hits FROM ex0709*.log GROUP BY cs-uri-stem ORDER BY
Hits DESC" -o:tpl -tpl mosthit.tpl > mosthit.htm
Note, this particular query is from the Jeff Atwater’s excellent blog post on Log Parser which you should definitely check out since he’s posted a number of other useful queries.
You can see I’ve narrowed the range of files to the month of September (ex0709*.log) and I need to come up with a scheduled task to produce rolling 30 day reports. Btw, the report could look substantially better and given Log Parser’s support for many different output format’s including a fun but rather useless “Matrix” style there are lots of possibilities. If you’ve created some useful/interesting templates I’d love to hear about them.
Anyway, with log parser in my toolbox I can start watching trends over time to learn more about usage and performance of the application. On to more immediate methods of analyzing perf!