Apache Logging Issues

Maintaining Apache logs poses an interesting problem. By default Apache logs to /var/log/httpd-error.log and /var/log/httpd-access.log. These files grow and grow over time and can fill up the partition and cause problems.

The obvious solution is log rotation via the system's log rotation service. On FreeBSD this is done via newsyslog. Normally this works fine, but Apache can't close files that are in the middle of a request. So when the logrotation service comes along and sends Apache a HUP signal so that it will close and reopen it's log files. For the most part Apache does that but sometimes a child will hold onto an inode that it is writing to. This will prevent the disk space from being reclaimed. This only normally only happens on high traffic systems.

The next solution people usually go for is a program called rotatelogs that is distributed with Apache. This program doesn't seem to solve the problem very well.

My perferred solution is using cronolog. This little app works similar to the way rotatelogs works, Apache pipes the logs into it. Cronolog can create directories as needed so if you want to have each year in its own directory, it is simple to do.

Powered by FreeBSD! r4l domain registration