Another milestone on the road to Zen with Ingeniweb components
Latest version : 1.0


> Let Zope rotate your log files with rotatezlogs <

About rotatezlogs

Let Zope rotate your log files with rotatezlogs

rotatezlogs has been designed by the INGENIWEB team.

rotatezlogs 1.0 is licensed under the GNU GPL license.

Do you like this product? You can support its authors by clicking the button below:
Support This Project


Our zope.conf log area:


The resulting instance log folder:




By Ingeniweb.


This product provides two additional logger handlers to the standard ones (see the doc in zope.conf) that rotate the log files.

It is not always possible to rotate Zope logs using system wide services. This utility enables to rotate automatically Zope logs (with or without zipping) using the features of the "logging" standard module.

Don't look for new objects in the ZMI factory. All is configured in zope.conf (see Installation below.)

This is mainly useful for Windows : rotating logs from an external utility while Zope is up is not possible.

Note that the log rotation rules is based on the actual size of a log file, and not on time periods (cron like).


Tested with Zope 2.8.6, Zope 2.9.3, Windows and Unix and may work (untested) with previous versions of Zope 2.8 and 2.9 series.

rotatezlogs does not require additional product.

Will not work with Zope 2.7.x. We should completely rework component.xml for this.


Inflate this product in the Products of your instance or some other place (see the products variable of $INSTANCE/etc/zope.conf).

Configure the rotating file logger handler

In any logger directive of zope.conf, change the handler as in this example for the <eventlog>.

%import Products.rotatezlogs

  # Usual options, see the doc in zope.conf
  level info
    # Required parameters
    # -------------------
    path $INSTANCE/log/event.log
    # We'll get up to 6 Mb of logs
    max-bytes 1MB
    backup-count 5

    # Optional parameters
    # -------------------
    # compression zip
    # format ------\n%(asctime)s %(levelname)s %(name)s %(message)s

This works for other logs too (access, trace).

When the size is about to be exceeded, the file is closed and a new file is silently opened for output. Rollover occurs whenever the current log file is nearly max-bytes in length; if max-bytes is zero, rollover never occurs. If backup-count is non-zero, the system will save old log files by appending the extensions ".1", ".2" etc., to the filename. For example, with a backup-count of 5 and a base file name of event.log, you would get event.log, event.log.1, event.log.2, up to event.log.5. The file being written to is always event.log. When this file is filled, it is closed and renamed to event.log.1, and if files event.log.1, event.log.2, etc. exist, then they are renamed to event.log.2, event.log.3 etc. respectively.

If you want compressed rotated log files, you can add the optional compression key parameter to the configuration. The value for compression can be:

  • none : the default, no compression is processed
  • zip : rotated files are zipped to etc.
  • gzip : rotated files are gzipped to xxx.log.1.gz etc.
  • bzip2 : rotated files are bzipped2 to xxx.log.1.bz2 etc.


Please read the .../rotatezlogs/tests/README.txt


Stay in tune with the latest releases of rotatezlogs...


$ cvs -d co rotatezlogs



The Ingeniweb team (c) 2006

Based on an idea by Mark Hammond.


Released versions

Released versions of rotatezlogs are available here. The current version is 1.0.

CVS version

The repository contains the up-to-date versions of our source code. In order to get the HEAD branch of rotatezlogs, use :

cvs -z3 co rotatezlogs

You can also browse the CVS with your browser.



Please take time the read the Readme



What about rotating at pre-defined period rather than size based condition?

Perhaps a future feature but :

  • The Python logging module doesn't provide such handler.
  • As a consequence, this requires more work than this one.
  • Consider sponsiring this feature if you really need it.

Why rotatezlogs doesn't support Zope 2.7.x?

  • Because the inners of the logging configuration have changed in depth with Zope 2.8. Most of the bindings and configuration definitions are in the component.xml file, and it's not possible to write auto adaptative XML code as we do in Python with "try...except" or such constructs.
  • Feel free to contribute and provide a component.xml that fits with Zope 2.7 configuration policy, as well as an auto adaptative scheme that supports Zope 2.8 and 2.9.
  • Or consider sponsiring the Zope 2.7 support if you really need it, but can't do it yourself.



rotatezlogs changes



  • Unified handlers (simpler to document and configure)
  • Added gzip and bzip2 compression modes.


  • Added unit tests
  • Enough testing, making a release candidate
  • Added rotation + zipping option


  • Initial release

rotatezlogs ChangeLog is also available for detailed informations.