Apache Rotate Logs and Log Rotate.

Peter Pluta peter at placidpublishing.net
Mon Mar 5 19:13:59 UTC 2007

Thanks, David. I had already configured it like that the first time 
around after reading up on it a bit. Most articles/tips I have read say 
to wait 10 minutes or so and then compress the logs with a shell script 
in order to be sure Apache finished logging to the files. Another thing, 
just to be sure. If I had 30 vhosts on my server and each had logs in 
their home directory, I would still use newsyslog to rotate and delete 
them, correct? I assume one needs tons of disk space to do that if the 
sites are rather large.

David Robillard wrote:
> 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/run/httpd.pid 30
> /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).
> HTH,
> David

More information about the freebsd-questions mailing list