[Twisted-Python] Twistd and Duplicate Logs

Andrew Francis andrewfr_ice at yahoo.com
Wed May 28 10:36:56 EDT 2008


Hi Folks:

I use a twistd server under Windows XP and Ubuntu. I
am using Twisted 8.0. I am using log rotation. I
essential copy the log example in Abe Fettig's book.

On a sidenote, I read that logs changed under Twisted
8.1? Should I move to that?

Under Windows XP, the programme runs as expected, it
generates logs  xxx.log, xxx.log.1, xxx.log.2

Under Ubuntu, it generates two sets of logs

xxx.log, xxx.log.1 and twistd.log, twisted.log.1

I am not sure why. What am I missing? Any advice would
be appreciated.

here is a sample of what I do:


class TheLog(log.FileLogObserver):
    
    def emit(self, logEntryDict):
        #if not logEntryDict.get('isError'): return
        log.FileLogObserver.emit(self, logEntryDict)


class TheLogService(service.Service):
    def __init__(self, logName, logDir):
        self.logName = logName
        self.logDir = logDir
        self.maxLogSize = MAX_LOG_FILE_SIZE
        self.theLog = TheLogBuilder()
    
    
    def getLogger(self):
        return self.theLog
    
    
    def startService(self):
        # logfile is a file-like object that supports
rotation
        self.logFile = logfile.LogFile(
            self.logName, self.logDir,
rotateLength=self.maxLogSize)
        self.logFile.rotate() # force rotation each
time restarted
        self.theLog = TheLog(self.logFile)
        self.theLog.start()


    def stopService(self):
        self.theLog.stop()
        self.logFile.close()
        del(self.logFile)


Cheers,
Andrew






      




More information about the Twisted-Python mailing list