Apache on Windows

The main hurdle to overcome is tying log submission into log rotation, which by default is not present. However, apache includes a binary, ~~rotatelogs.exe~~ that handles the task. The steps are as follows:

- Generate a private key as described in the general Apache client setup
- Set Apache logging to __combined__ as in general Apache client setup
- Edit the http.conf and add this line: (the number 86400 is the number of seconds in a day, for daily rotation)
{quote}
    CustomLog "| bin/rotatelogs.exe logs/access.%Y%m%d.log 86400" combined
{quote}
- Use a batch file like the below example to submit the logs
{code:none}
set HOST=workforce
Set DIR="C:\Program Files\Apache Software Foundation\Apache2.2\logs"
set FILES=access.*.log
set DEST=stats@stats.cats.ohiou.edu:data/logs/%HOST%

date /t >> SendLogs.log

echo Y | pscp -C -q -2 -i %HOST%.ppk %DIR%\%FILES% %DEST% >> SendLogs.log 2>&1

forfiles /p %DIR% /m *.log /d -1 /c "cmd /c ren @FILE *.old"
{code}

__Note:__

The bin allows you to rename the file __while it is open__. This is why we have to use the ~~forfiles~~ trick, rather than just a rename.

Some people report bugs with this approach  (multiple instances of the binary preventing apache from shutting down and starting properly) However, this is still the apache best practice and the bugs hasn't been observed directly by us.

There are 3rd party apache modules that handle log rotation. We've tried them and found them to be more work for no clear benefit.


Comments