2018年2月17日 星期六

Apache logs rotation

XAMPP中apache的(\xampp\apache\logs]) access log和error log會隨時間增長,
可利用 (\xampp\apache\bin\) rotatelogs.exe 來 rotate log:

修改 (\xampp\apache\conf\) httpd.conf,運用 rotatelogs.exe 每 86400 秒產生一個檔案:
#ErrorLog "logs/error.log"
ErrorLog "|D:/xampp/apache/bin/rotatelogs.exe D:/xampp/apache/logs/error-%Y%m%d.log 86400"

#CustomLog "logs/access.log" combined
CustomLog "|D:/xampp/apache/bin/rotatelogs.exe D:/xampp/apache/logs/access-%Y%m%d.log 86400" combined

如啟用SSL,須同步修改 http-ssl.conf:
#ErrorLog "D:/xampp/apache/logs/error.log"
ErrorLog "|D:/xampp/apache/bin/rotatelogs.exe D:/xampp/apache/logs/error-%Y%m%d.log 86400"

#TransferLog "D:/xampp/apache/logs/access.log"
TransferLog "|D:/xampp/apache/bin/rotatelogs.exe D:/xampp/apache/logs/access-%Y%m%d.log 86400"

#CustomLog "D:/xampp/apache/logs/ssl_request.log" \
          "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
CustomLog "|D:/xampp/apache/bin/rotatelogs.exe D:/xampp/apache/logs/ssl_request-%Y%m%d.log 86400" \

          "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"

沒有留言: