Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

We're running Apache 2.2.9 (Win32) with a few virtual hosts configured on the one server. Each has it's own ErrorLog and CustomLog settings which are in the format of "logs/[domain name]-error.log" and "logs/[domain name]-access.log". Unfortunately these are now creating quite large files.

On IIS you can specify the log schedule, which can put them in a daily format of "yymmdd.log". Is there something similar I can do here?

It doesn't have to be daily either, weekly or monthly will do. I'd just like to break them up so that we can keep X amount instead of everything it's ever logged. A quick Google seems to bring up lots of Linux orientated answers involving log splitters, scripts and cron jobs which isn't too helpful for a Windows installation.

Update

Thanks to radius, I tweaked my httpd-vhosts.conf to use Apache's built in rotatelogs command, in the following format:

ErrorLog "|bin/rotatelogs logs/[domain name]-error.%Y-%m-%d-%H_%M_%S.log 5M" CustomLog "|bin/rotatelogs logs/[domain name]-access.%Y-%m-%d-%H_%M_%S.log 5M" common

They'll create a new log file when the current one reaches 5MB. I know that's not daily as asked for, but that keeps them at a manageable size which will do. I did try the rotate after so many seconds but it didn't seem to be putting the time stamp in the file name correctly (specifically hours, minutes and seconds).

share|improve this question
add comment

3 Answers

up vote 6 down vote accepted

What you're looking for is the rotatelogs program that comes with apache http://httpd.apache.org/docs/2.2/programs/rotatelogs.html

For instance, to rotate your logs daily at midnight:

CustomLog "|bin/rotatelogs -f /var/log/apache2/logfile.%Y.%m.%d.log 86400" common
share|improve this answer
    
+1, didn't know Apache had a solution of it's own. –  Karolis T. Jun 17 '09 at 9:14
add comment

What you want is called log rotation.

Google seems to list some revelant links about log rotation tools for windows.

This seems like an Apache specific solution, maybe it'll help you:

http://www.sprint.net.au/~terbut/usefulbox/apachelogrot.htm

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.