Logging with Cronolog
I have been experimenting with Cronolog, developed by Andrew Ford, who also authored the Apache Pocket Reference, published by O’Reilly and Associates.
I elected to work with cronolog based on a recommendation from a peer and the fact that the log files for the site in question were unmanageable in size. You may remember it being briefly mentioned at the end of my column on Apache web logs.
This handy program allows for logs to be broken down by day, month and year. I chose a middle ground and have them set to rotate to new logs on the first of each month.
Installation is very easy. After downloading and unpacking — simply use ./configure and make to build the executable. You can then copy src/cronolog to where you want to call it from. I used /usr/local/sbin/cronolog.
Usage is fairly straightforward as well. I noted a snippet from my httpd.conf below to show how it integrates into the Apache log config inside of virtual servers.
CustomLog “|/usr/local/sbin/cronolog /home/domains/mydomain.com/logs/%Y/%m/access_log” combined
ErrorLog “|/usr/local/sbin/cronolog /home/domains/mydomain.com/logs/%Y/%m/error_log”
The cronolog program is called and reads log message input and manages the log file, also conveniently creating a folder hierarchy in your logs folder by month and year as it creates each month’s new log file.
Now my logs folder looks like this:
Within the 2004 directory I see 07 and 08 directories for July and August, each that contain an access_log and error_log for the month.
A final note — the Cronolog credits Klaus Mueller with creating a Windows binary for cronolog to run on Windows systems. The download is here.