Rotate Apache log files they easy way

Here is how I configured access.log, ssl_request.log and error.log to rotate at midnight every day.

Put this below script in a file named rotateall.cmd and schedule a task to run at 12:00am every day.

Change the paths and service name to sute the setup.

@echo off

REM Apache Log Rotation Script

REM The location of the squid log files
SET APACHE_LOG_PATH=C:\Apache22\logs

REM Stop Apache service
net stop Apache2.2

REM date format
REM FOR /F "tokens=1-4 delims=/ " %%j in ('date /t') do set YYYYMMDD=%%l-%%k-%%j

REM date format
FOR /F "tokens=1-4 delims=/, " %%i in ('date /t') do set YYYYMMDD=%%l-%%k-%%j

REM Rename the log file
ren "%APACHE_LOG_PATH%\access.log" "access-%YYYYMMDD%.log"
ren "%APACHE_LOG_PATH%\error.log" "error-%YYYYMMDD%.log"
ren "%APACHE_LOG_PATH%\ssl_request.log" "ssl_request-%YYYYMMDD%.log"

REM Restart the squid service
net start Apache2.2