| 1 |
.\" -*- nroff -*- |
| 2 |
.\" $Id: cronolog.1m,v 1.5 1999/12/20 09:03:50 andrew Exp $ |
| 3 |
.\" Copyright (c) 1999 Apache Software Foundation |
| 4 |
.\" Copyright (c) 1996-1999 Andrew Ford and Ford & Mason Ltd. |
| 5 |
.\" The file License specifies the terms and conditions for redistribution. |
| 6 |
.TH cronolog 1m "March 1998" |
| 7 |
|
| 8 |
.SH NAME |
| 9 |
cronolog \- write log messages to log files named according to a template |
| 10 |
|
| 11 |
.SH SYNOPSIS |
| 12 |
cronolog [\fIOPTION\fR]... \fItemplate\fR |
| 13 |
|
| 14 |
.SH DESCRIPTION |
| 15 |
.B cronolog |
| 16 |
is a simple program that reads log messages from its input and writes |
| 17 |
them to a set of output files, the names of which are constructed |
| 18 |
using |
| 19 |
.B template |
| 20 |
and the current date and time. The template uses the same format |
| 21 |
specifiers as the Unix |
| 22 |
.BR date (1) |
| 23 |
command (which are the same as the standard C strftime library |
| 24 |
function). |
| 25 |
.PP |
| 26 |
Before writing a message |
| 27 |
.B cronolog |
| 28 |
checks the time to see whether the current log file is still valid and |
| 29 |
if not it closes the current file, expands the template using the |
| 30 |
current date and time to generate a new file name, opens the new file |
| 31 |
(creating missing directories on the path of the new log file as |
| •32 |
needed unless the program is compiled with \-DDONT_CREATE_SUBDIRS) and |
| 33 |
calculates the time at which the new file will become invalid. |
| 34 |
.PP |
| 35 |
.B cronolog |
| 36 |
is intended to be used in conjunction with a Web server, such as |
| 37 |
Apache to split the access log into daily or monthly logs. For |
| 38 |
example the Apache configuration directives: |
| 39 |
.LP |
| •40 |
TransferLog "|/usr/bin/cronolog /www/logs/%Y/%m/%d/access.log" |
| 41 |
ErrorLog "|/usr/bin/cronolog /www/logs/%Y/%m/%d/errors.log" |
| 42 |
.LP |
| 43 |
would instruct Apache to pipe its access and error log messages into |
| 44 |
separate copies of cronolog, which would create new log files each day |
| 45 |
in a directory hierarchy structured by date, i.e. on 31 December 1996 |
| 46 |
messages would be written to |
| 47 |
.LP |
| 48 |
/www/logs/1996/12/31/access.log |
| 49 |
/www/logs/1996/12/31/errors.log |
| 50 |
.P |
| 51 |
after midnight the files |
| 52 |
.LP |
| 53 |
/www/logs/1997/01/01/access.log |
| 54 |
/www/logs/1997/01/01/errors.log |
| 55 |
.P |
| 56 |
would be used, with the directories 1997, 1997/01 and 1997/01/01 being |
| 57 |
created if they did not already exist. (Note that prior to version 1.2 Apache |
| 58 |
did not allow a program to be specified as the argument of the |
| 59 |
ErrorLog directive.) |
| 60 |
|
| 61 |
.SH Options |
| •62 |
.B cronolog |
| 63 |
accepts the following options and arguments: |
| 64 |
.\" |
| 65 |
.IP "-H \fINAME\fP" |
| 66 |
.IP "--hardlink=\fINAME\fP" |
| 67 |
maintain a hard link from |
| 68 |
.I NAME |
| 69 |
to the current log file. |
| 70 |
.\" |
| 71 |
.IP "-S \fINAME\fP" |
| 72 |
.IP "--symlink=\fINAME\fP" |
| 73 |
.IP "-l \fINAME\fP" |
| 74 |
.IP "--link=\fINAME\fP" |
| 75 |
maintain a symbolic link from |
| 76 |
.I NAME |
| 77 |
to the current log file. |
| 78 |
.\" |
| 79 |
.IP "-P \fINAME\fP" |
| •80 |
.IP "--prev-simlink=\fINAME\fP" |
| 81 |
maintain a symbolic link from |
| 82 |
.I NAME |
| 83 |
to the previous log file. Requires that the |
| 84 |
.B "--symlink" |
| 85 |
option is specified, as cronolog renames the current link to the name |
| 86 |
specified for the previous link. |
| 87 |
.\" |
| •88 |
.IP "-h" |
| 89 |
.IP "--help" |
| 90 |
print a help message and then exit. |
| 91 |
.\" |
| 92 |
.IP "-p \fIPERIOD\fP" |
| 93 |
.IP "--period=\fIPERIOD\fP" |
| 94 |
specifies the period explicitly as an optional digit string followed |
| 95 |
by one of units: \fBseconds\fP, \fBminutes\fP, \fBhours\fP, |
| 96 |
\fBdays\fP, \fBweeks\fP or \fBmonths\fP. The count cannot be greater |
| 97 |
than the number of units in the next larger unit, i.e. you cannot |
| 98 |
specify "120 minutes", and for seconds, minutes and hours the count |
| 99 |
must be a factor of the next higher unit, i.e you can specify 1, 2, 3, |
| 100 |
4, 5, 6, 10, 15, 20 or 30 minutes but not say 7 minutes. |
| 101 |
.\" |
| 102 |
.IP "-d \fIPERIOD\fP" |
| 103 |
.IP "--delay=\fIPERIOD\fP" |
| 104 |
specifies the delay from the start of the period before the log file |
| 105 |
is rolled over. For example specifying (explicitly or implicitly) a |
| 106 |
period of 15 minutes and a delay of 5 minutes results in the log files |
| 107 |
being rotated at five past, twenty past, twentyfive to and ten to each |
| 108 |
hour. The delay cannot be longer than the period. |
| 109 |
.\" |
| 110 |
.IP "-o" |
| 111 |
.IP "--once-only" |
| 112 |
create single output log from template, which is not rotated. |
| 113 |
.\" |
| 114 |
.IP "-x FILE" |
| 115 |
.IP "--debug=\fIFILE\fP" |
| 116 |
write debug messages to |
| 117 |
.I FILE |
| 118 |
or to the standard error stream if |
| 119 |
.I FILE |
| 120 |
is "-". (See the README file for more details.) |
| 121 |
.\" |
| 122 |
.IP "-s TIME" |
| 123 |
.IP "--start-time=\fITIME\fP" |
| 124 |
pretend that the starting time is |
| 125 |
.I TIME |
| 126 |
(for debugging purposes). |
| 127 |
.I TIME should be something like "DD MONTH YYYY HH:MM:SS" (the day and |
| 128 |
month are reversed if the american option is specified). If the |
| 129 |
seconds are omitted then they are taken as zero and if the hours and |
| 130 |
minutes are omitted then the time of day is taken as 00:00:00 |
| 131 |
(i.e. midnight). The day, month and year can be separated by spaces, |
| •132 |
hyphens (\-) or solidi (/). |
| 133 |
.\" |
| •134 |
.IP "-a" |
| 135 |
.IP "--american" |
| 136 |
Interprete the date part of the starting time the American way (month |
| 137 |
then day). |
| •138 |
.IP "-e" |
| 139 |
.IP "--european" |
| 140 |
Interprete the date part of the starting time the European way (day |
| 141 |
then month). This is the default. |
| 142 |
.\" |
| •143 |
.IP "-v" |
| 144 |
.IP "--version" |
| 145 |
print version information and exit. |
| 146 |
.\" |
| 147 |
.\" |
| 148 |
.\" .IP "-p \fIprogram\fP" |
| 149 |
.\" postprocess each logfile using program once a new logfile is created. |
| 150 |
.\" \fIprogram\fP is invoked with the name of the previous logfile as its |
| 151 |
.\" argument. |
| 152 |
.\" |
| 153 |
.\" |
| 154 |
.SH Template format |
| 155 |
Each character in the template represents a character in the expanded |
| 156 |
filename, except for date and time format specifiers, which are |
| 157 |
replaced by their expansion. Format specifiers consist of a `%' |
| 158 |
followed by one of the following characters: |
| 159 |
.IP % |
| 160 |
a literal % character |
| 161 |
.IP n |
| •162 |
a new\-line character |
| 163 |
.IP t |
| 164 |
a horizontal tab character |
| 165 |
.PP |
| 166 |
Time fields: |
| 167 |
.IP H |
| 168 |
hour (00..23) |
| 169 |
.IP I |
| 170 |
hour (01..12) |
| 171 |
.IP p |
| 172 |
the locale's AM or PM indicator |
| 173 |
.IP M |
| 174 |
minute (00..59) |
| 175 |
.IP S |
| 176 |
second (00..61, which allows for leap seconds) |
| 177 |
.IP X |
| 178 |
the locale's time representation (e.g.: "15:12:47") |
| 179 |
.IP Z |
| 180 |
time zone (e.g. GMT), or nothing if the time zone cannot be determined |
| 181 |
.PP |
| 182 |
Date fields: |
| 183 |
.IP a |
| 184 |
the locale's abbreviated weekday name (e.g.: Sun..Sat) |
| 185 |
.IP A |
| 186 |
the locale's full weekday name (e.g.: Sunday .. Saturday) |
| 187 |
.IP b |
| 188 |
the locale's abbreviated month name (e.g.: Jan .. Dec) |
| 189 |
.IP B |
| 190 |
the locale's full month name, (e.g.: January .. December) |
| 191 |
.IP c |
| 192 |
the locale's date and time (e.g.: "Sun Dec 15 14:12:47 GMT 1996") |
| 193 |
.IP d |
| 194 |
day of month (01 .. 31) |
| 195 |
.IP j |
| 196 |
day of year (001 .. 366) |
| 197 |
.IP m |
| 198 |
month (01 .. 12) |
| 199 |
.IP U |
| 200 |
week of the year with Sunday as first day of week (00..53, where week |
| 201 |
1 is the week containing the first Sunday of the year) |
| 202 |
.IP W |
| 203 |
week of the year with Monday as first day of week (00..53, where week |
| 204 |
1 is the week containing the first Monday of the year) |
| 205 |
.IP w |
| 206 |
day of week (0 .. 6, where 0 corresponds to Sunday) |
| 207 |
.IP x |
| 208 |
locale's date representation (e.g. today in April in Britain: "13/04/97") |
| 209 |
.IP y |
| 210 |
year without the century (00 .. 99) |
| 211 |
.IP Y |
| 212 |
year with the century (1970 .. 2038) |
| 213 |
.P |
| 214 |
Other specifiers may be available depending on the C library's |
| 215 |
implementation of the |
| 216 |
.B strftime |
| 217 |
function. |
| 218 |
.P |
| 219 |
.SH SEE ALSO |
| 220 |
.BR apache (1m) |
| 221 |
.BR date (1) |
| 222 |
.BR strftime (3) |
| 223 |
.BR environ (5) |
| 224 |
.PP |
| 225 |
More information and the latest version of |
| 226 |
.B cronolog |
| 227 |
can be obtained from |
| 228 |
.LP |
| •229 |
http://www.ford\-mason.co.uk/resources/cronolog/ |
| 230 |
.LP |
| 231 |
If you have any suggestions, bug reports, fixes, or enhancements, |
| 232 |
please mail them to the author. |
| 233 |
.SS More about Apache |
| 234 |
Documentation for the Apache http server is available from |
| 235 |
.LP |
| 236 |
http://www.apache.org |
| 237 |
.\" |
| 238 |
.SH FUTURE DIRECTIONS |
| 239 |
The functionality of |
| 240 |
.B cronolog |
| 241 |
could be built into Apache, thus saving the overhead of having a |
| 242 |
process per log stream and that of transferring data from the server |
| 243 |
process to the cronolog process. The main complication is handling |
| 244 |
the case where multiple log streams are written to the same file |
| 245 |
(template), for example where different virtual servers write to the |
| 246 |
same set of log files. |
| 247 |
.SH AUTHOR |
| •248 |
Andrew Ford <A.Ford@ford\-mason.co.uk> |
| 249 |
.LP |
| 250 |
.B cronolog |
| 251 |
is based on a program called |
| 252 |
.B rotatelogs |
| 253 |
by Ben Laurie, which is packaged with the Apache web server. |
| 254 |
.LP |
| 255 |
The symbolic link |
| 256 |
.\" and postprocessing options were |
| 257 |
option was suggested by Juergen Lesny. |