windows apache access.log 分割 ログ ローテート
apacheのログを日ごとに分割して保存する
下記ではWindoesでXamppのapacheを使用した場合
xampp\apache\conf下にある
httpd.confを編集する
ErrorLog "| bin/rotatelogs.exe logs/error_%Y%m%d.log 86400" CustomLog "| bin/rotatelogs.exe logs/access_%Y%m%d.log 86400" common
sslを使用しているときは
xampp\apache\conf\extra下にある
httpd-ssl.confも編集する
ErrorLog "| bin/rotatelogs.exe logs/error_%Y%m%d.log 86400" CustomLog "| bin/rotatelogs.exe logs/access_%Y%m%d.log 86400" common CustomLog "| bin/rotatelogs.exe logs/ssl_request_%Y%m%d.log 86400" "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
以下で削除用のバッチを作成してタスクスケジューラーに登録しておく
@echo off for /f "skip=30" %%F in ('dir /b /o-n access_????????.log') do del %%F for /f "skip=30" %%F in ('dir /b /o-n error_????????.log') do del %%F