Using the MS LogParser for rough statistics#

A few weeks ago, Steve Trefethen published his Blog entry Publishing IIS log file analysis using Microsoft Log Parser, where he outlined how to use the free software MS Log Parser to run a basic analysis of the log files created by IIS. Today I set up my task scheduler to run two basic tasks once a day to generate Summaries on the most read blog entries as well as the top downloaded files from my conference page.

The whole setup process took less than 20 minutes to figure out how to format the query, to create the templates for displaying them within this blog layout and to setup the scheduler tasks. The last task was the "hardest", as you cannot use parameters when using the scheduler interface. After figuring out that problem, I simply created the batch files and pointed the task scheduler to them, which in turn run the queries.

If you like to use those tasks for your DasBlog site, simply install the MS Log Parser on your server and adjust the following calls.

The Top 50 Requested Pages

logparser.exe 
"SELECT TOP 50 
  to_lowercase(cs-uri-stem) as Url, COUNT(cs-uri-stem) AS Hits 
FROM
  D:\LogFiles\W3SVC2106058385\ex*.log 
WHERE 
  (to_lowercase(cs-uri-stem) NOT LIKE '%%captchaimage%%') AND
  ((to_lowercase(cs-uri-stem) = '/blog') OR 
(to_lowercase(cs-uri-stem) = '/blog/default.aspx') OR
(to_lowercase(cs-uri-stem) like '/blog/20%%.aspx')) GROUP BY Url ORDER BY Hits DESC" -o:tpl -tpl "D:\Sites\Blog\Content\Special\mosthits.format.tpl" > "D:\Sites\Blog\Content\Special\mosthits.format.html"

The Downloads-Counter

logparser.exe 
"SELECT TOP 50 
  to_lowercase(cs-uri-stem) as Url, COUNT(cs-uri-stem) AS Hits 
FROM
  D:\LogFiles\W3SVC2106058385\ex*.log 
WHERE
  (to_lowercase(cs-uri-stem) like '/downloads/%%')
GROUP BY 
  Url 
ORDER BY
  Hits DESC"
-o:tpl -tpl "D:\Sites\Blog\Content\Special\downloads.format.tpl" > "D:\Sites\Blog\Content\Special\downloads.format.html"

The .tpl-files are formatted similar to the ones shown in Steve's blog.

Friday, October 05, 2007 12:51:55 PM (W. Europe Standard Time, UTC+01:00) #    Comments [2]  | 

 

Google AdSense


Friday, October 05, 2007 7:41:39 PM (W. Europe Standard Time, UTC+01:00)
Daniel, I use the LogParser over 4 years and you've forgot an interesting thing: the logParser isn't only a exe, there is a dll-file too... and with this dll you can use the power of the LogParser inside your application !
Friday, October 05, 2007 7:48:53 PM (W. Europe Standard Time, UTC+01:00)
Hi Thomas,

you are right for the fact that it deploys with a DLL too, however I did not forget, it just was not part of interest for this part :-D

However, currently I am trying to figure out how it works w/o using log parser directly. Basically it should simply convert the log files into CSV and run it through ADO, or?
Comments are closed.
All content © 2008, Daniel Wischnewski
On this page
Archives
Promoted Links
Blogroll OPML
My current Flickr Images
www.flickr.com
Dies ist ein Flickr Modul mit �ffentlichen Fotos und Videos von dwischnewski. Ihr eigenes Modul k�nnen Sie hier erstellen.
Recommendations
Sitemap
Special Pages
Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

Theme design by Jelle Druyts