Forum Moderators: phranque

Message Too Old, No Replies

Log filename and rotation

         

frist44

1:25 pm on Mar 10, 2009 (gmt 0)

10+ Year Member



Is there a way to specify a date parameter in the log filename so that they're rotate on a daily basis?

Frank_Rizzo

1:36 pm on Mar 10, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I don't think it would be practical as apache would have to check if the date / time had changed every time something is to be logged.

For linux the easiest way would be to use the logrotate app. This will rotate, compressing etc.

Another option would be to use a cron job to run at midnight. This would rename the file to the date and touch a new file. Will probably need to stop / start apache whilst this is happening.

webdoctor

1:42 pm on Mar 10, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Apache includes the rotatelogs [httpd.apache.org] program for this very purpose. I've used it for years in my httpd.conf - like this:

<VirtualHost *:80>
CustomLog "¦/usr/sbin/rotatelogs /var/log/apache2/access_log.%y%m%d 86400" vcommon
</VirtualHost>

meaning I get a new log file every day, named access_log.YYMMDD

frist44

2:14 pm on Mar 10, 2009 (gmt 0)

10+ Year Member



We're actually using WAMP on windows, so is there a solution that would take that platform into account?

frist44

1:02 pm on Mar 11, 2009 (gmt 0)

10+ Year Member



I found the rotate logs program that's part of the wamp package and that worked.