You can configure Apache's own program Rotatelogs functionality in Apache's httpd.conf configuration file .
Rotatelogs is a simple program that works with the Apache pipeline log feature,
Reference: http://httpd.apache.org/docs/current/mod/mod_log_config.html
1 Create a new log every day
Customlog "|/usr/sbin/rotatelogs/etc/httpd/logs/access_log_%y-%m-%d 86400 480" combined
2nd log more than a certain size to generate new logs
Customlog "|/usr/sbin/rotatelogs/etc/httpd/logs/access_log_%y-%m-%d 5M" combined
3 rotatelogs Syntax
Rotatelogs[ -L]logfile [ Rotationtime [ offset ] | [ FileSize m]
-
-
logfile
-
-
it adds the base name to the log file name. If logfile "%" is included, it is treated as
strftime()
the format string used, otherwise it is automatically appended with the " .nnnnnnnnnn " suffix in seconds. Both formats represent the time when the new log began to be used.
-
-
rotationtime
-
The
-
interval of time in seconds that the log file is scrolled.
-
-
offset
-
-
the number of minutes of the time difference relative to UTC. If omitted, it is assumed to be "0" and UTC time is used. For example, to specify local time for a region with a UTC difference of "-5 hours", this parameter should be "
-300
".
-
-
filesizeM
-
-
specifies scrolling as a
filesizeM
file size instead of scrolling by time or slack.
-
-
- Examples of settings under Windows are as follows:
# Limit error log file to 1M
Errorlog "|bin/rotatelogs.exe-l logs/error-%y-%m-%d.log 1M"
# Generate an error log file every day
#ErrorLog "|bin/rotatelogs.exe logs/error-%y-%m-%d.log 86400"
# Limit access log file to 1M
Customlog "|bin/rotatelogs.exe-l logs/access-%y-%m-%d.log 1M" common
# Generate one access log file per day
#CustomLog "|bin/rotatelogs.exe logs/access-%y-%m-%d.log 86400" common
Limit Apache log access.log file size