Ask HN: Best approach to Apache logging?

2 points by akavlie ↗ HN
I set up a virtual server on Linode recently, and mimicked their suggested Virtual Host settings like so:

  ErrorLog /srv/www/ducklington.org/logs/error.log
  CustomLog /srv/www/ducklington.org/logs/access.log combined
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!

For that reason, Apache docs recommend log rotation:

  CustomLog "|/usr/local/apache/bin/rotatelogs 
    /var/log/access_log 86400" common
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.

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.)?

2 comments

[ 3.4 ms ] story [ 14.6 ms ] thread
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.
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.