Adding Custom Logfile to OS X (Server) Log Rotation

The earlier posts on my logging experiences didn't include the log-rotation solution I used on my OS X Server.

When you create a new log file (and have syslog fill that file up), you're gonna run into a lack of space sooner or later. This happens because the syslog server keeps writing data to that file, and the system doesn't 'recognize' (read: isn't configured) the file for log-rotation. So, you need to tell the log-rotation process to include the new log file (and what to do with it).

In the latest version of OS X you can use the /etc/newsyslog.conf file to include your custom log file. This configuration file allows you to add (at least) the following parameters:

  • Count
    How many files are kept before they're deleted
  • Size in kB
    Maximum file size of the uncompressed raw logfile which triggers to rotate to a new log file (and compressing the old one).
  • When
    A time frame for compressing the log files. Entering 24 would rollover the log every 24-hours.

My entry for my SRX firewall logging has the following markup:

/var/log/srx.log                        640 10    10000 *     J

So, my log files rotates @10MB in size, and I keep 10 (compressed) old log files.

I restarted the server to apply the changes. Could be that restarting a (syslog??)service could also solve it, but my server had a reboot coming anyway.

Posted on March 28, 2011 and filed under Apple, Tips'n Tricks.