Skip to content
IT // Adventures

Log Rotation for Apache Httpd on Windows

With mod_log_rotate, Apache can also create daily logs. For this, the 'CustomLog' directive is extended with strftime()-compatible parameters.

1 min read

With mod_log_rotate, Apache can also create daily logs. For this, the “CustomLog” directive is extended with strftime()-compatible parameters.

Configuration

The module provides the following directives (excerpt from the docs):

  • RotateLogs On|Off: Enable / disable automatic log rotation. Once enabled mod_log_rotate takes responsibility for all log output server wide even if RotateLogs Off is subsequently used. That means that the BufferedLogs directive that is implemented by mod_log_config will be ignored.
  • Rotate LogsLocalTime On|Off: Normally the log rotation interval is based on UTC. For example an interval of 86400 (one day) will cause the logs to rotate at UTC 00:00. When this option is on, log rotation is timed relative to the local time.
  • RotateInterval []: Set the interval in seconds for log rotation. The default is 86400 (one day). The shortest interval that can be specified is 60 seconds. An optional second argument specifies an offset in minutes which is applied to UTC (or local time if RotateLogsLocalTime is on). For example RotateInterval 86400 60 will cause logs to be rotated at 23:00 UTC.

The corresponding entries in httpd.conf:

LoadModule log_rotate_module modules/mod_log_rotate.so

Example

To create daily logs that rotate at 00:00 local time, adjust the CustomLog directive as follows:

<IfModule log_rotate_module>
  CustomLog "logs/access_%Y%m%d.log" combined
  RotateLogs On
  RotateLogsLocalTime On
</IfModule>

Sources