rotatelogs - Piped logging program to rotate Apache logs
For use in to
rotatelogs [ -l ] [ -f ] logfile rotationtime|filesizeM [ offset ]
Program for use with Apache's piped logfile feature, supports rotation based on a time inte val or maximum size of the log.
|use local time rather than GMT as the base for the interval or strftime formatting with size-based rotation. |
in an environment which changes the GMT offset (such as for
DST) this can lead to unpredictable results!
| force logfile to be opened immediately, |
instead of waiting for the first entry to be read (for non-busy sites, there may be a substantial delay between when the server is started and when the first request is handled, meaning that the associated logfile does not "exist" until then, which causes problems from some automated logging tools).
| seconds between log file rotations. The rotation occurs at the beginning of this interval. |
3600, at the beginning of every hour; (60*60)
86400, every night at midnight. 24*60*60
If no data is logged during an interval, no file will be created.
| size in megabytes (suffixed by |
M to distinguish size from a time.
|minutes offset from UTC. Default: zero UTC is used. |
For example, to use local time in the zone UTC -5 hours, specify
-300 . use of
-l is prefered.
Create a log where
nnnn is the time at which the log nominally starts (this time will always be
a multiple of the rotation time, synchronized with cron scripts with it).
At the end of each rotation time ( 24 * 60 * 60 =86400 here after 24 hours) start a new log.
CustomLog "|bin/rotatelogs /var/logs/logfile 86400" common
Create a new log file every day at midnight
CustomLog "|bin/rotatelogs -l /var/logs/logfile.%Y.%m.%d 86400" common
Rotate the logfile when it reaches a 5 megabytes.
CustomLog "|bin/rotatelogs /var/logs/logfile 5M" common
Rotate the error logfile whenever it reaches a 5 megabytes
ErrorLog "|bin/rotatelogs /var/logs/errorlog.%Y-%m-%d-%H_%M_%S 5M"
| date and time †
| 4-digit year |
| 2-digit month
| month †|
| 3-character month† |
| 3-digit day of year
| 2-digit day
|2-digit hour (00-24 ) |
|2-digit hour (00-12)
|am/pm of 12 hour clock†|
|2-digit week of year|
week starts on Sunday
|2-digit week of year |
week starts on Monday
|1-digit weekday |
week starts on Sunday
| weekday† |
| 3-character weekday †