How to get log files rotate in Zope with buildout


— Update : this tip requires Zope 2.11 or Plone 4 —

Zope server includes natively some undocumented option since Zope 2.10 2.11 that allows to rotate log files. They started from the Gilles Lenfant work for iw.rotatezlogs.

The only documenation I found was in ZConfig module test by searching about ‘max-size’ : http://svn.zope.org/ZConfig/trunk/ZConfig/components/logger/tests/test_logger.py?view=markup

To use it in your buildout you should add following code in each intance part :

event-log-custom =
    <logfile>
        path ${buildout:directory}/var/log/instance.log
        #max-size = 5mb
        when D
        old-files 366
    </logfile>

access-log-custom =
    <logfile>
        path ${buildout:directory}/var/log/instance-Z2.log
        #max-size = 5mb
        when D
        old-files 366
    </logfile>

That’s all folks !

9 Responses to How to get log files rotate in Zope with buildout

  1. Alex Clark dit :

    Nice! I guess that means that iw.rotatezlogs is no longer necessary😉 (which means I should fix my book…)

    • encolpe dit :

      Yes iw.rotatezlogs is not anymore necesaary. We should use this since Plone uses Zope 2.10 but when we start to have some habits it’s difficult to search into sources if new undocumented functionalities are coming.
      I’m sorry to raise this so late.

  2. Dietrich dit :

    Very nice and thank you.

    I’ve added this to my buildout.cfg, but it returns error:
    /***
    root@dtschmitz:/usr/local/Plone/zinstance# bin/plonectl start
    instance: Error: ‘when’ is not a known key name
    (line 34 in file:///u
    ***/

    An otherwise great idea.
    Any ideas on how to fix?

    Kindest Regards,
    Dietrich T. Schmitz

  3. Jota dit :

    Hello!

    Thank you for the tip, but it should be good to explain what the options above do??

    Jorge

    • Like said the Zope undocumentation
      when: truncate every period
      – D for every day
      – M for every month
      – Y for every year (maybe)

      max-size: truncate when size file size is reached
      – support mb for MegaByte

      old-files: how many old files you want to keep

%d blogueurs aiment cette page :