This has changed since my days at Pyramid. There has been quite a lot of thinking and engineering about dealing with daemon logs. The places to look are via the syslogd, newsyslog project, you can see a the newsyslog man pages and using the keyword “rotate log”. The idea is that logs are rotated, although the names are not and that old logs are deleted. So the newest is called mypackage or mypackage.0 and the older logs increment the counter. Logs are generally kept in /var/log or /var/log/package_name and not in the package or product install tree. What a nob? There is a command ‘logrotate’; it can be installed using macports. It needs a a configuration file.

Linux

I moved on from Mac, along time ago, and have incorporated logrotate into my apt cron jobs. I found the man page and this article, which contains examples. My apt conf file is on github, and here,

/var/apt/apt-update.log {
    weekly
    rotate 5
    compress
    missingok
    notifempty
}

Daemons

Or Liunux/MacOS out of the box, I found these pages

Batch Programs

I have a problem today, I want to run a script periodically, on a laptop which will create a run log and I want to keep the logs tidy but each run is to have one log. I think I’ll write a function file since newlog is designed for daemons and I would need to manage the problem that my run needs to test the target log is empty before writing. I think I’ll refactor my functions to use logrotate. I now have the habit of placing the logs in /opt/local/log/appname and I place the conf files there too. It would be possible to place the conf files, if not job based in /etc and probably have a end of/start of day job rotate the logs.

2 Replies

  1. I just amended the page to include direct reference to logrotate which I missed the first time round…idiot.

  2. Time to look again; many features of Linux seem to use logrotate managed logs. have the habit of placing the logs in /opt/local/log/appname and I place the conf files there too. It would be possible to place the conf files, if not job based in /etc and probably have a end of/start of day job rotate the logs.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.