Rotating logs with apache under windows

Mike had a question about rotating the apache logs under windows (with Uniform Server as he was struggling to get it to work. Looking at google and various other locations it seems to be a common problem but very few people had the solution (or the whole solution).
What I found that is if you edit the httpd.conf stored in the usr\local\Apache2\conf directory and add the 2 lines

#rotate logs set here
CustomLog “|w:/usr/local/apache2/bin/rotatelogs.exe w:/usr/local/apache2/logs/access_log 86400” common

just before the <directory /> section then the logs will get rotated every day. Change the 86400 to 61 for once a minute (61 secs to be precise) to test it first.
The .exe on the end of rotatelogs is important (and that seems to be the bit missing from every other page) and naturally the logs directory and the path to rotatelogs.exe needs to exist. The files will start access_log and will have the date and time stamp at the end of the filename.
I include the line starting with a # as a comment but this line is not strictly needed. You will need to stop and start apache for this change to take effect. If any of the paths are incorrect, you will probably find that the welcome page for the web server appears but no other pages on the website will work. If that is the case, then check your path statements to the exe file and to the log directory.
One disadvantage of this is that the rotatelogs.exe file fires up in a dos box (on my machine) but this can be minimised out of harms way but it would be nice to not have this on the machine. I think running apache as a service might solve this problem, but the advantage of uniform server is that the whole thing can be run from a removable disk with no installation required.


  1. Mike McBride

    Thanks Andy, I think I’ve got it now. The instructions I had seen left out the EXE too, and also didn’t include stopping and restarting the server. That was kind of an important step that I probably should have known better. This is Windows after all… 🙂

  2. TK

    I’ve tried this method but it didn’t work. My questions are:

    1. Where (in httpd.conf) should I place these lines?

    2. What will the result look like?

    3. I’m using Apache 2. Does it make any difference?

    Thank you.

Comments are closed.