apache USES the log segmentation module rotatelogs to partition logs

  • 2020-05-07 20:49:46
  • OfStack

rotatelogs is the pipeline logger that comes with Apache 2.2

grammar


rotatelogs [ -l ] logfile [ rotationtime [ offset ]] | [ filesizeM ]

options
-l
Use local time instead of GMT time as the time reference. Note: using -l in an environment that changes the GMT offset (such as daylight saving time) can cause unpredictable results.

logfile
This plus the base name is the log file name. If "%" is included in logfile, it is considered a format string for strftime(). Otherwise it will be automatically suffixed with ".nnnnnnnnnn "in seconds. Both of these formats indicate when the new log is started.

rotationtime
The interval in seconds during which a log file rolls.

offset
Number of minutes of time difference with respect to UTC. If omitted, assume "0" and use UTC time. For example, to specify the local time for an area with a time difference of "-5 hours" for UTC, this parameter should be "-300".

filesizeM
Specifies to scroll at filesizeM file size instead of by time or time difference.

Usage in the master configuration file


ErrorLog "|bin/rotatelogs -l logs/error_%Y%m%d.log 86400"
CustomLog "|bin/rotatelogs -l logs/access_%Y%m%d.log 86400" combined
[code]

 Usage in the virtual host configuration file 
[code]
ServerAdmin webmaster@localhost
DocumentRoot "E:/htdocs"
ServerName localhost
ErrorLog "|bin/rotatelogs -l logs/localhost/error_%Y%m%d.log 86400"
CustomLog "|bin/rotatelogs -l logs/localhost/access_%Y%m%d.log 86400" combined

Here is one log file per day, restart apache and you're done! The above rotatelogs is your apache path


Related articles: