Henrik Thostrup Jensen
thostrup at gmail.com
Thu Feb 8 07:37:24 EST 2007
On 2/8/07, Martin Evans <martin at browns.co.uk> 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.
>From a quick look at log.py it does not appear that calling startLogging
again would stop logging to the old, it would just add another log observer,
meaning that log entries would go to both files.
One approach is to create your own log observer and using this to log with.
Then you can change file whenever you want to, and also change the log
layout etc.. Alternatively you can call removeObserver and addObserver when
you want to change log file.
Another approach is to use an external program to rotate the log files.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Twisted-Python