script to add dates to IIS web log files

Steve Holden sholden at holdenweb.com
Mon Sep 11 09:25:37 EDT 2000


Greg Jorgensen wrote:
> 
> I wrote this script last night to add dates to each line of web server log
> files if the date is missing. This is apparently a Microsoft IIS feature: if
> you don't configure it to add dates to each line it puts the date in a #date
> header at the top of the file. The analog web log analyzer doesn't like
> this. I downloaded a VBScript script to fix this from the analog web site,
> but it could only process one file at a time, so I wrote my own.
> 
> I'm still learning Python so this may not be the most elegant
> implementation, but it does work and is fast. And I can use it on an entire
> directory or set of files specified with wildcards.
> 
Well done!

> Does anyone know if IIS writes another #Date: header into the middle of the
> log file if the date changes while the log file is active? If so my script
> doesn't account for that. If log file spans two days it won't be detected. I
> should probably make the script check for times lower than the previous
> time, which would indicate rolling past midnight.
> 
Yes, if you set log rollover to weekly, you get date headers at the
change of date, so you'll need to update your code.

[code snipped]

If you're happy with a single output file for multiple input files you
might want to take a look at the fileinput standard modlue.

regards
 Steve
-- 
Helping people meet their information needs with training and technology.
703 967 0887      sholden at bellatlantic.net      http://www.holdenweb.com/



More information about the Python-list mailing list