

Ask HN: Best approach to Apache logging? - akavlie

I set up a virtual server on Linode recently, and mimicked their suggested Virtual Host settings like so:<p><pre><code>  ErrorLog /srv/www/ducklington.org/logs/error.log
  CustomLog /srv/www/ducklington.org/logs/access.log combined
</code></pre>
However I've discovered that this is not an ideal setup -- on the main site running on this server, the access log has grown to 1.8GB in just a couple of weeks!<p>For that reason, Apache docs recommend log rotation:<p><pre><code>  CustomLog "|/usr/local/apache/bin/rotatelogs 
    /var/log/access_log 86400" common
</code></pre>
This would have to be modified of course, for distro-specific location of the rotatelogs command, desired location for the log file, and rotation interval.<p>So how do you handle log rotation? As above from the Apache docs, or with some other method?
And while we're at it, any other customization you've done (formatting, etc.)?
======
jedsmith
I use the logrotate package, which is included with most distros. With Ubuntu,
most packages include a logrotate configuration for themselves. For this
specific virtual host configuration, you could add your own logrotate
instruction for it -- look in /etc/logrotate.d.

~~~
akavlie
Cool, thanks. That looks ideal -- it's already in use for the main Apache logs
by default, just not for the sites I've configured under /srv/www/*.

A single line added to the apache2 file under /etc/logrotate.d and I think all
my logs are covered.

