in reply to Re: moving old files
in thread moving old files

++ brd. I was just going to recommend chronolog.

Chronolog uses the Apache feature of logging to another process instead of to a file. This means you do not have to do:
- rename all of the log files - HUP apache - then archive the old log fles however you like
The best part is apache does not stop reponding for a short while during the HUP. I used to admin for a company that ran several hundred virtual hosts per apache install. That HUP can be noticable.

Chronolog takes care of creating and renaming files for you as time goes by. I use something like the following:
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent} +i\"" combined ErrorLog "|/usr/local/sbin/cronolog /log/web/domain.com/%Y-%m-%d_err +or.log" CustomLog "|/usr/local/sbin/cronolog /log/web/domain.com/%Y-%m-%d_ac +cess.log" combined
This setup gives me one access log and one error log per calendar day. I think you can setup log files per hour or minute if you want to.

Replies are listed 'Best First'.
Re^3: moving old files
by brd (Acolyte) on Apr 21, 2006 at 05:06 UTC
    The only problem I have noticed with using Cronolog is that it adds two processes everytime it is used. If you have lots of virtual hosts and a cronolog for the ErrorLog & CustomLog that adds four processes per VirtualHost.
     
    Edit: It seems that only on Apache 1.3 does apache create two processes for a piped logging program. It forks a shell and then runs cronolog. I'm seeing this in an Apache 1.3 server:
    13311 ?? I 0:00.00 /bin/sh -c /usr/local/sbin/cronolog /usr/log +s/httpd/%Y/%m/access_log 13314 ?? I 0:00.36 /usr/local/sbin/cronolog /usr/logs/httpd/%Y/ +%m/access_log
    vs. on Apache 2.0:
    29394 ?? I 0:00.04 /usr/local/sbin/cronolog /usr/logs/httpd/%Y/ +%m/access_log
Re^3: moving old files
by pbaumgar (Acolyte) on May 17, 2006 at 19:33 UTC
    Hello again,
    I've decided to use Cronolog for Apache logging. I have cronolog creating logs with like this: %m-%Y/access_log. So it will seperate all the logs my months. What is the best way to handle the month change in my original script? I'd like at the end of them month to gzip the entire directory and dump it in the archive directory. Do I use a file/directory test to check the timestamp on it?
    my $log_dir = "/etc/httpd/logs/2006"; my $archive_dir = "/etc/httpd/logs/archive";