[Twisted-Python] startLogging

Jean-Paul Calderone exarkun at divmod.com
Thu Feb 8 13:36:58 EST 2007

On Thu, 08 Feb 2007 10:19:39 -0800, Steve Freitas <sflist at ihonk.com> wrote:
>On Thu, 2007-02-08 at 12:14 +0000, Martin Evans wrote:
>> Are there any samples on how best to interact with logging?
>> My server needs to log quite a few items, as such the log file is
>> growing quite quickly and I would like to be able to switch file
>> names on a daily basis. I would also probably then wish to delete
>> logs older than 14 days.
>> I'm not sure how safe it would be to just keep calling startLogging()
>> with a different file name mid-session. I realise there has been some
>> discussion about this area recently.
>Twisted includes a class, twisted.python.logfile.LogFile, which
>implements rotation. It does not, however, do auto-deletion. So I did
>this on Twisted 2.5 (no idea if 2.4's any different), which saves x old
>logs. If you want to discriminate by age, I'd suggest subclassing
>logfile.DailyLogFile and using a similar approach.

FWIW, there's a patch which adds similar functionality in the tracker
(or maybe it has been applied to trunk by now, I can't remember).  So
in the next Twisted release this will probably be available, although
it is not yet clear how it will be exposed via the twistd commandline.


More information about the Twisted-Python mailing list