cronolog(1m) | cronolog(1m) |
cronolog - write log messages to log files named according to a template
cronolog [OPTION]... template
cronolog is a simple program that 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(1) command (which are the same as the standard C strftime library function).
Before writing a message cronolog checks the time to see whether the current log file is still valid and if not it closes the current file, expands the template using the current date and time to generate a new file name, opens the new file (creating missing directories on the path of the new log file as needed unless the program is compiled with -DDONT_CREATE_SUBDIRS) and calculates the time at which the new file will become invalid.
cronolog is intended to be used in conjunction with a Web server, such as Apache to split the access log into daily or monthly logs. For example the Apache configuration directives:
TransferLog "|/usr/bin/cronolog /www/logs/%Y/%m/%d/access.log"
ErrorLog "|/usr/bin/cronolog /www/logs/%Y/%m/%d/errors.log"
would 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
/www/logs/1996/12/31/access.log
/www/logs/1996/12/31/errors.log
after midnight the files
/www/logs/1997/01/01/access.log
/www/logs/1997/01/01/errors.log
would be used, with the directories 1997, 1997/01 and 1997/01/01 being created if they did not already exist. (Note that prior to version 1.2 Apache did not allow a program to be specified as the argument of the ErrorLog directive.)
cronolog accepts the following options and arguments:
Each character in the template represents a character in the expanded filename, except for date and time format specifiers, which are replaced by their expansion. Format specifiers consist of a `%' followed by one of the following characters:
Time fields:
Date fields:
Other specifiers may be available depending on the C library's implementation of the strftime function.
apache(1m) date(1) strftime(3) environ(5)
More information and the latest version of cronolog can be obtained from
http://www.ford-mason.co.uk/resources/cronolog/
If you have any suggestions, bug reports, fixes, or enhancements, please mail them to the author.
Documentation for the Apache http server is available from
http://www.apache.org
The functionality of cronolog could be built into Apache, thus saving the overhead of having a process per log stream and that of transferring data from the server process to the cronolog process. The main complication is handling the case where multiple log streams are written to the same file (template), for example where different virtual servers write to the same set of log files.
Andrew Ford <A.Ford@ford-mason.co.uk>
cronolog is based on a program called rotatelogs by Ben Laurie, which is packaged with the Apache web server.
The symbolic link option was suggested by Juergen Lesny.
March 1998 |