Reputation: 56636
How can I force Apache (part of WAMP) to write the new logs in the new log files without restarting the server?
In Apache2\conf\httpd.conf I updated the path for ErrorLog
and CustomLog
directives.
before:
ErrorLog ../logs/a.log
...
CustomLog ../logs/b.log common
after:
ErrorLog ../logs/a2.log
...
CustomLog ../logs/b2.log common
The LogLevel
and LogFormat
directives were not changed.
After I changed them, I managed (I don't know how - accidentally or it was done automatically, but I am sure that I didn't restart the server explicitly) to get the new logs in the new files. Maybe this didn't happen immediately, because I observed this after 20 minutes (the new log files were created and the new logs went to them, not to the old ones). This is what I wanted to achieve!
But then I changed the paths again:
../logs/a2.log
=> ../logs/a3.log
../logs/b2.log
=> ../logs/b3.log
but the logs didn't go to the new path (they were still written to ../logs/a2.log
and ../logs/b2.log
).
I was thinking at the following 2 possible approaches that could solve my problem, but probably there is another approach:
ErrorLog
and CustomLog
lines to be updated (in terms of executing some commands directly in cmd, ignoring the httpd.conf file).Details:
Upvotes: 4
Views: 2300
Reputation: 17872
On Windows, apache.exe -k restart
is mildly graceful -- in-flight requests have 30 seconds to complete.
Beyond this, you're probably out of luck for a safe way to rename files being written to on Windows. You should never be running a single HTTP server for this very reason. You have no way to do any routine maintenance.
Upvotes: 1
Reputation: 41
To answer this question correctly you need to tell me which logging api is being used in your apache configuration.
If using log4j then see the following URL Log4j Automatic Configuration
You will find information here which talks about setting the monitorInterval property, in the Log4j configuration file. Setting this attribute to a non-zero value ( > 5) will result in the file being checked the next time a log event is evaluated and/or logged and the monitorInterval, specified in seconds, has elapsed since the last check
Upvotes: 1