How can I rotate PHP Log files on Windows Server 2003?

Solution 1:

If you are using Apache to run PHP then there is a built-in utility called rotatelogs that you can pipe your logs through and it will automatically do the log rotation for you. Here is how you use it on Windows:

ErrorLog "|bin/rotatelogs.exe -l logs/error/error.%Y-%m-%d.log 86400"

Another alternative is to set the PHP error log location in run-time to a file that includes the date, i.e. add this to your prepend file:

ini_set('error_log', 'path_to_logs/php_error.'.date('Y-m-d').'.log');