Log file rotation, log file naming conventions

(1)
I set up several sites in SA with enabled logging, but have the problem that log files are growing indefinitely when there is no webstat software.

Is there a way in configuration files to set up something like "archive logs each seven days, rotate (in the meaning of delete) the oldest log after two archive cycles" ? Or more simpler clear the log file as soon as it reaches a given size ?

(2)
Is it safe for my webstat software when it deletes the access and error log files after processing it ? Or should the files itself be kept ?

I ask this, because on an other server OS I noticed when deleting the access_log file, for example, the server stops logging overall. So not sure how it is here.

(3)
I noticed that archived logs are named like "access_log.1162166400" - can someone explain the mysterious number added ? Seconds (since when) ? I had imagined a date stamp or anything like that, but that seems not to be the case.

Mac OS X (10.4.8)

Posted on Nov 6, 2006 11:12 AM

Reply
2 replies

Nov 6, 2006 5:28 PM in response to tobias Eichner

>Is there a way in configuration files to set up something like "archive logs each seven days, rotate (in the meaning of delete) the oldest log after two archive cycles" ? Or more simpler clear the log file as soon as it reaches a given size ?

The log file rotation is managed by the process rotatelogs. You'll find in your site's configuration file something like:

<pre class=command>CustomLog '|/usr/sbin/rotatelogs "/var/log/httpd/access_log" 86400' combined</pre>
which writes the 'combined' format access log to the specified file, rotating the file every day (86,400 seconds).

If you prefer the log files to rotate at a given size rather than time period you can do that by specifying xM rather than number of seconds, e.g.:

<pre class=command>CustomLog '|/usr/sbin/rotatelogs "/var/log/httpd/access_log" 1024M' combined</pre>

will rotate when the logs reach 1GB in size.

There's a completely separate process that cleans up old logs, managed by the /etc/periodic scripts. You can edit those scripts to clean up old logs. Off hand I can't remember how many old logs it keeps - 4 comes to mind but you should probably check.

Note that you cannot set the custom intervals of file sizes via the GUI, and that if you change the site via the Server Admin GUI your changes are likely to be lost.

>Is it safe for my webstat software when it deletes the access and error log files after processing it ? Or should the files itself be kept ?

You should not delete the active log file, but you can delete the rotated ones any time you like.

>I noticed that archived logs are named like "access_log.1162166400" - can someone explain the mysterious number added ? Seconds (since when) ? I had imagined a date stamp or anything like that, but that seems not to be the case.

The number is based on the number of seconds since the epoch (Jan 1 1970). You can pump the number into date -r to see what it translates to in a human-readable format:

<pre class=command># date -r 1162166400
Sun Oct 29 16:00:00 PST 2006</pre>

The time will be rounded to the interval of the rotatelogs period - that is if you're rotating the logs once per day the datestamp will be rounded back to the previous interval.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Log file rotation, log file naming conventions

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.