[Twisted-Python] Log rotates not as expected

Lucas Taylor ltaylor.volks at gmail.com
Thu Jan 21 18:13:03 EST 2010

On 1/21/10 11:17 AM, Pet wrote:
> On Thu, Jan 21, 2010 at 7:02 PM, Maarten ter Huurne
> <maarten at treewalker.org> wrote:
>> On Thursday 21 January 2010, Lucas Taylor wrote:
>>> This can occur if you have multiple instances of logfile.LogFile setup
>>> to manage the same file. The default rotation is 1MB, so maybe you have
>>> another logfile.LogFile somewhere?
>> Maybe twistd's log rotation?
> Yes, may be. I start my daemon with
> /usr/bin/twistd -y mydaemon.py --logfile=/var/log/my.log
> --pidfile=/var/lock/mydaemon.pid
> How do I start twistd, so it doesn't produce own log file?
> Thanks for help!
> Pet

You can customize the application to use your logfile and observer:

class MyLog(log.FileLogObserver):
    def emit(self, logEntryDict):
        log.FileLogObserver.timeFormat = '%Y-%m-%d %H:%M:%S'
        log.FileLogObserver.emit(self, logEntryDict)

maxLogSize = 5000000
logFile = logfile.LogFile("my.log", "/var/log", rotateLength=maxLogSize,

application = service.Application("myapp")
application.setComponent(log.ILogObserver, MyLog(logFile).emit)

More information about the Twisted-Python mailing list