Package: iw.rotatezlogs
ByIngeniweb.AboutThis product provides two additional logger handlers to the standard
ones (see the doc inzope.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 inzope.conf(seeInstallationbelow.)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, andnoton time periods (cron like).RequirementsTested with Zope 2.8, Zope 2.9, Zope 2.10, Windows and Unix.rotatezlogsdoes not require additional product.Will not work with Zope 2.7.x. We should completely reworkcomponent.xmlfor this.Installation$ easy_install [options] iw.rotatezlogsConfigure the rotating file logger handlerIn any logger directive ofzope.conf, change the handler as in this
example for the <eventlog>.%import iw.rotatezlogs

<eventlog>
  # Usual options, see the doc in zope.conf
  level info
  <rotatelogfile>
    # 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
  </rotatelogfile>
</eventlog>This works for other logs too (access, trace, zeo, …).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 nearlymax-bytesin length; ifmax-bytesis
zero, rollover never occurs. Ifbackup-countis non-zero, the system
will save old log files by appending the extensions “.1”, “.2” etc.,
to the filename. For example, with abackup-countof 5 and a base
file name ofevent.log, you would getevent.log,event.log.1,event.log.2, up toevent.log.5. The file being written to is
alwaysevent.log. When this file is filled, it is closed and renamed
toevent.log.1, and if filesevent.log.1,event.log.2,
etc. exist, then they are renamed toevent.log.2,event.log.3etc. respectively.If you want compressed rotated log files, you can add the optionalcompressionkey parameter to the configuration. The value forcompressioncan be:none: the default, no compression is processedzip: rotated files are zipped toxxx.log.1.zipetc.gzip: rotated files are gzipped toxxx.log.1.gzetc.bzip2: rotated files are bzipped2 toxxx.log.1.bz2etc.Note that some systems or Python installations come with no bzip2
support. In such case, we usenonecompression as fallback. You can
test the bzip2 support like this:$ python
...
>>> import bz2Install and configure a zope instance with buildoutThe easiest way. Edit yourbuildout.cfg:[instance]
...
eggs =
  ...
  iw.rotatezlogs
  ...

event-log-custom =
  %import iw.rotatezlogs
  <rotatelogfile>
    path ${buildout:directory}/var/log/instance.log
    max-bytes 1MB
    backup-count 5
  </rotatelogfile>

access-log-custom =
  %import iw.rotatezlogs
  <rotatelogfile>
    path ${buildout:directory}/var/log/instance-Z2.log
    max-bytes 1MB
    backup-count 5
  </rotatelogfile>See previous section for detailed explanations.Copyright and licenseCopyright (c) 2006-2008 Ingeniweb SASThis software is subject to the provisions of the GNU General Public License,
Version 2.0 (GPL).  A copy of the GPL should accompany this distribution.
THIS SOFTWARE IS PROVIDED “AS IS” AND ANY AND ALL EXPRESS OR IMPLIED
WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
FOR A PARTICULAR PURPOSESee the…/rotatezlogs/LICENSEfile that comes with this product.TestingPlease read the…/rotatezlogs/tests/README.txtDownloadStay in tune with the latest releases ofrotatezlogs…Subversion reposo:https://ingeniweb.svn.sourceforge.net/svnroot/ingeniweb/iw.rotatezlogs/Releases:http://pypi.python.org/pypi/iw.rotatezlogsSupportMail to Ingeniweb supportDonations are welcome for new featuresCreditsThe Ingeniweb team(c) 2006-2008Main developer:Gilles LenfantEggification:Tarek ZiadeBased on an idea by Mark Hammond.