Apache Rotate Logs and Log Rotate.
david.robillard at gmail.com
Mon Mar 5 18:57:00 UTC 2007
On 3/3/07, Peter Pluta <peter at placidpublishing.net> wrote:
>> I see, thanks. Does the shell script you use automatically delete the
>> original logs after verbalizer or awstats makes it's own? I imagine the
>> ones those programs use are smaller in size?
> No, the shell script does not delete any logs. Log rotation and
> compression is the job of newsyslog.
Alright, after some more RTFM on Apache logs, here's what your
newsyslog.conf(5) configuration should look like.
/var/log/httpd/access.log 640 5 1048576 * B
/var/log/httpd/error.log 640 5 1048576
* B /var/run/httpd.pid 30
Of course, you should taylor this to suit your own needs (like the
size, ownership and number logs kept on disk, etc.)
But keep the "B" flag for Binary which will prevent newsyslog from
adding a line in your logs which says it was rotated. It _may_ confuse
some log analyser (depends on your log analyser software). Also make
sure to add the "30" at the end of each line. This is the kill(1)
number for signal -USR1 which gracefully restarts Apache.
Now the reason I removed the "Z" flags, which eliminates compression,
is to make sure all of your children httpd processes have enough time
to write their logs into the log file. If a request on your site is
rather long, them this is the best way to go. Of couse, that means you
will need a little bit more disk space. But not that much depending on
how much logs you keep (i.e. 5 in the example above).
UNIX systems administrator & Oracle DBA
CISSP, RHCE & Sun Certified Security Administrator
Montreal: +1 514 966 0122
More information about the freebsd-questions