2011年2月16日 星期三

Apache log rotate

http://httpd.apache.org/docs/2.2/programs/rotatelogs.html
修改httpd.conf
#CustomLog "logs/access.log" common
CustomLog "|D:/Apache/bin/rotatelogs.exe -l D:/Apache/logs/access.%Y-%m-%d_%H_%M_%S.log 10M" common

#ErrorLog "logs/error.log"
ErrorLog "|D:/Apache/bin/rotatelogs.exe -l D:/Apache/logs/error.%Y-%m-%d_%H_%M_%S.log 10M"
修改後,重新啟動 Apache

若是長路徑須改為8.3格式的短路徑
CustomLog "|C:/PROGRA~1/apache~1/apache2.2/bin/rotatelogs.exe C:/PROGRA~1/apache~1/apache2.2/logs/access.%Y-%m-%d_%H_%M_%S.log 10M" common


Apache 在 2.4.5 版後,可指定 log 最多保留幾個
https://httpd.apache.org/docs/2.4/programs/rotatelogs.html
-n number-of-files
Use a circular list of filenames without timestamps. With -n 3, the series of log files opened would be "logfile", "logfile.1", "logfile.2", then overwriting "logfile". Available in 2.4.5 and later.


沒有留言:

張貼留言