Mar 17 2005

Learning about Cronolog

Tag:markmaldony @ 11:50

Use cronolog to Rotate Your Web Server Log Files.

The cronolog program reads log messages from its input and writes them to a set of output files, the names of which are constructed using template and the current date and time. The template uses the same format specifiers as the UNIX date command (which are the same as the standard C strftime library function).

Installation
To install cronolog, follow the instructions that correspond to your Virtual Server O/S.
FreeBSD & Solaris
Connect to your Virtual Server via Telnet or SSH and run this command:

% vinstall cronolog

Usage
cronolog is intended to be used in your Virtual Server Web Server Configuration File (~/www/conf/httpd.conf) to split the access log file, or other log files, into daily or monthly log files, like in the following example.

TransferLog “|/usr/local/cronolog/cronolog /www/logs/%Y/%m/%d/access.log”
ErrorLog “|/usr/local/cronolog/cronolog /www/logs/%Y/%m/%d/errors.log”The sample configuration directives above instruct Apache to pipe its access and error log messages into separate copies of cronolog, which would create new log files each day in a directory hierarchy structured by date, i.e. on 31 December 1996 messages would be written to the following files.

~/www/logs/1996/12/31/access.log
~/www/logs/1996/12/31/errors.log
After midnight the following filenames would be written, with the directories 1997, 1997/01 and 1997/01/01 being created if they did not already exist.

~/www/logs/1997/01/01/access.log
~/www/logs/1997/01/01/errors.log