Question

I have a strange problem:

I use Apache on Windows and tried to configure rotating log using mod_log_rotate with the following configuration:

RotateLogs On
RotateLogsLocalTime On
RotateInterval 86400
CustomLog "C:\logdir\access_%d-%m-%Y-%H-%M-%S.log" common

However this results in a file named as follows:

access_03-05-2013-00-00-00.log

So it works for the date-part, i.e. %d, %m, %Y, but does not work for the parts below date, i.e. hour, minute, second via %H, %H, %S.

According to the source of mod_log_rotate, it uses apr_strftime(), which itself seems to use strftime(). I also looked at Microsofts implementation of strftime, it seems to support the same elements.

So how comes it cannot replace those hour/minute/second items? Is this a Window-specific restriction?

Was it helpful?

Solution

In the meantime I found out why this happens: The timestamp used is "normalized" according to the RotateInterval, which means that if you use 86400, hours, minutes and seconds are always set to 0. By setting RotateInterval to 3600 (i.e. one hour), the hour value is set correctly.

It's not intuitive and not documented (in fact the whole filename-pattern replacement is more or less undocumented unless I missed it somewhere), but with this setting it seems to work as I intended in the first place.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top