Revision 1 as of 2008-07-31 14:11:41

Clear message

4.7. How can I rotate my Mailman logs?

Eric Toran's logrotate tool is recommended:

  http://rpmfind.net/linux/redhat/code/logrotate/

LogRotate is installed by default with most Linux distributions. Debian/Linux users are particularly well off in that the Debian Mailman package automatically installs a LogRotate configuration wlong with Mailman.

You may encounter problems using logrotate with MM 2.1.x because the qrunners run as daemons rather than cron jobs. They thus tend to hold open file descriptors to log files for their (indefinite) lifetime. You may need to wrap invocation of mailmanctl stopping and then starting the qrunners around the invocation of logrotate in order to get things to work right. Well thats what I found worked but if you have a better idea then update this FAQ page.

Example configuration stanza for Mailman for LogRotate (based on but not identical to the Debian defaults):

  /var/log/mailman/bounce {
        weekly
        missingok
        create 0664 list list
        rotate 4
        compress
        delaycompress
  }

  /var/log/mailman/digest {
        monthly
        missingok
        create 0664 list list
        rotate 4
        compress
        delaycompress
  }

  /var/log/mailman/error {
        weekly
        missingok
        create 0664 list list
        rotate 4
        compress
        delaycompress
  }

  /var/log/mailman/post {
        monthly
        missingok
        create 0664 list list
        rotate 12
        compress
        delaycompress
  }

  /var/log/mailman/smtp-failure {
        daily
        missingok
        create 0664 list list
        rotate 7
        compress
        delaycompress
  }

  /var/log/mailman/smtp {
        daily
        missingok
        create 0664 list list
        rotate 7
        compress
        delaycompress
  }

  /var/log/mailman/locks {
        daily
        missingok
        create 0664 list list
        rotate 7
        compress
        delaycompress
  }

  /var/log/mailman/fromusenet {
        daily
        missingok
        create 0664 list list
        rotate 7
        compress
        delaycompress
  }

  /var/log/mailman/qrunner {
        daily
        missingok
        create 0664 list list
        rotate 7
        compress
        delaycompress
  }

  /var/log/mailman/subscribe {
        monthly
        missingok
        create 0664 list list
        rotate 12
        compress
        delaycompress
  }

  /var/log/mailman/vette {
        weekly
        missingok
        create 0664 list list
        rotate 4
        compress
        delaycompress
  }

Ok, Richard that's the long way. I use a shorter way :-)

File /etc/logrotate.d/mailman

/home/mailman/logs/* {

weekly
missingok
rotate 52
nomail
compress
delaycompress
notifempty
create 664 mailman mailman
olddir /home/mailman/logs/old
sharedscripts
postrotate
if \[ -f /home/mailman/data/master-qrunner.pid \]; then \
/etc/init.d/mailman restart > /dev/null; fi
endscript
\\

}

For the non-Linux folks, the included "newsyslog" in *BSD will do a similar job.

Example /etc/newsyslog.conf entry:

/usr/local/mailman/logs/bounce mailman:mailman 640 5 1000 * Z /usr/local/mailman/data/master-qrunner.pid

...and so forth for each log file.

\''\_

Hopefully this is an even better way:

The diff below, against MM v2.1.9 changes logfile names to *.log, thus enabling your logroate script to not have to use olddir, nor do you have to have multiple logrotate stanzas, one per file. Use as follows:

File /etc/logrotate.d/mailman:

\-------------------------
/home/mailman/logs/*.log
{         weekly         missingok         rotate 52         nomail         compress         delaycompress         notifempty         create 664 mailman mailman         sharedscripts         postrotate            if [ -f /home/mailman/data/master-qrunner.pid ]; then \                 /etc/init.d/mailman restart > /dev/null; fi         endscript  }
\-------------------------
\\

Mailman v2.1.9 diff:

\-------------------------

\++\+ Logging/Logger.py           2007-04-06 21:11:18.600639072 -0400
--- Logging/Logger.py.old       2007-04-06 21:10:05.672725800 -0400
@@ -43,7 \+43,6 @@
Otherwise, the file is created only when there are writes pending.
"""
self.__filename = os.path.join(mm_cfg.LOG_DIR, category)
+        self.__filename \+= '.log'
self.__fp = None
self.__nofail = nofail
self.__encoding = LOG_ENCODING or sys.getdefaultencoding()

\-------------------------

NOTE: if you use mmdsr, you need to modify it to change ERR_LOGS and SUM_LOGS to update the new .log names. Additionally, you will need to change almost every line that contains "

" to correct the logfile name the if statements are trying to match. If you don't do this, then your mmdsr report will be much more verbose. ;-)
Hth,

-Jim P. (jimpop@yahoo.com)

Last changed on Sun Apr 15 02:02:50 2007 by Jim Popovitch Converted from the Mailman FAQ Wizard

This is one of many Frequently Asked Questions.