Hello,
I have apache installed on Windows XP.
But the logs are getting quit big now.
Is there a way to rotate them, or overwrite them?
So they don't get to big? 100MB is really to much data.
Solved: Rotate apache logs in windows
Re: Rotate apache logs in windows
You can use rotatelogs.exe to manage the logs.
rotatelogs.exe can be found in the apache2/bin/
Should create a new log every day. (86400 seconds)
You can als create a new one on size:
Create a new log file when the log file is larger then 5MB
rotatelogs.exe can be found in the apache2/bin/
Code: Select all
CustomLog "| bin\rotatelogs.exe logs\access%Y_%m_%d.log 86400"
You can als create a new one on size:
Code: Select all
CustomLog "| bin\rotatelogs.exe logs\access.log 5M"
Re: Rotate apache logs in windows
I tried your solution.
But when i add the line, the server doesn't want to start.
But when i add the line, the server doesn't want to start.
Re: Rotate apache logs in windows
Sorry, my mistake the full line should read:
dont forget to set the root dir:
(Normally this is already done at the beginning of the file/)
Code: Select all
CustomLog "| bin\rotatelogs.exe logs\access%Y_%m_%d.log 86400" common
dont forget to set the root dir:
Code: Select all
ServerRoot "C:/Program Files/Apache Group/Apache2"
Re: Rotate apache logs in windows
I added common,
and the server now starts, but it doesn't seam to update the log-file.
and the server now starts, but it doesn't seam to update the log-file.
Re: Rotate apache logs in windows
Perhaps if you add the full pathname of the log file?
Hi, buddy, thanks for your article.
this article help me a lot, I am very aprreciated for it. thank you very much.
Re: Rotate apache logs in windows
Arch you need to put the slashes right,
This should work:
This should work:
Code: Select all
CustomLog "| bin/rotatelogs.exe logs/access%Y_%m_%d.log 86400" common
Re: Solved: Rotate apache logs in windows
The logrotate that comes with Apache, doesn't zip or delete files.
I made a litlle bat-file that zips and delete the old zip files.
I let it run every month, but you can run it once a week, or ...
I made a litlle bat-file that zips and delete the old zip files.
Code: Select all
@ECHO OFF
SET datum=%Date:~-4,4%_%Date:~-7,2%_%Date:~-10,2%
SET logdir=c:\Program Files\Apache Group\Apache2\logs\
SET holdzipfiles=7
::go to dir
cd %logfir%
::gets all the log files with 20 in from 2009 (will break in 2100, but by then you shouldn't be a beter system)
dir /B *20*.log | find /V "%datum%.log" > filestoarchive.dat
::If at first it doesn't work, it might be something with the quotes.
::Zip it, and delete old file
FOR /F %%a IN (filestoarchive.dat) DO (
"c:\program files\winzip\wzzip" -ex -u "%logdir%logs.%datum%.zip" "%logdir%%%a"
del "%logdir%%%a"
)
::del filelist
del filestoarchive.dat
::check zip files
dir /B /O-D logs.*.zip > zipfiles.dat
::we hold the first ? files and delete the rest
FOR /F "skip=%holdzipfiles%" %%a IN (zipfiles.dat) DO (
del %%a
)
del zipfiles.dat
::the end