Problem
Apache is a popular web server. It logs every access and error error. If Apache is ran for for a long time, its access log and error log file can be huge.
Solution
Most Linux include a small program called rotatelogs, which can limit log file size.
The line below limit error log to 10M. If error log is bigger than 10M, rotatelogs creates a new file with file name “erorlog.YYY-mm-dd-H_MM_SS”
ErrorLog “|bin/rotatelogs /var/www/our_site/logs/errorlog.%Y-%m-%d-%H_%M_%S 10M”
The line below limit access log to 10M. If access log is bigger than 10M, rotatelogs creates a new file with file name “accesslog.YYY-mm-dd-H_MM_SS”
CustomLog “|bin/rotatelogs /var/www/our_site/logs/accesslog.%Y-%m-%d-%H_%M_%S 10M” combined
You need to restart apache for these two configuration to take effect.
Reference:
rotatelogs – Piped logging program to rotate Apache logs