log size handling

David Newman dnewman at networktest.com
Thu Jul 17 18:56:54 UTC 2008

On 7/17/08 7:10 AM, Matthew Seaman wrote:

>  * Use the rotatelogs program that comes with Apache.  In this case,
>    you replace the logging configuration statements in https.conf
>    eg. instead of:
>         CustomLog "/var/log/httpd-access.log" combine
>    you have:
>         CustomLog "|/usr/local/sbin/rotatelogs /var/log/httpd-access.log 
> 86400"
>    which will create a new log file every 86400 seconds (= 1 day) and
>    label each one with the unix time it was created appended to the
>    name. eg:
>        /var/log/httpd-access.log.1216252800
>    That will change files at midnight UTC each day, which is fine
>    if your server lives in the UK but not quite as convenient if your
>    server is in Australia.

Yes. Apache's rotatelogs is a better choice than newsyslog. Under heavy 
load, the latter can corrupt Apache logs.

rotatelogs also can do changes based on log size, like this:

CustomLog "|/usr/local/sbin/rotatelogs/var/log/httpd-access.log 5M" \

and if you don't like deciphering Unix epoch time, you can embed times 
in your log filenames like this:

CustomLog "|/usr/local/sbin/rotatelogs \
/var/log/httpd-access.log.%Y-%m-%d-%H_%M_%S 86400" combined

(n.b. I added the backslashes in the examples here; you want everything 
on a single line in your config file.)


More information about the freebsd-questions mailing list