[Twisted-Python] Need for multiple loggers...

Chaz. eprparadocs at gmail.com
Sat Jun 10 09:39:48 MDT 2006


Thanks but I think that answers the wrong question. In my original
application I have three different named loggers (the original app
is written in Python). I have logOp, logTrace, logDebug each of which
goes somewhere different (for instance logOp messages go to the
operators system, logDebug is sent to a non-rotated file and logTrace
goes to a rotating log file). Through out my application I will log
message to the appropriate logger, for example messages that I want
written out to the debug file I write as logDebug.msg(...). Those that I
want to trace objects moving around I will do logDebug.info(...). etc.

In Twisted.python.log it looks like there is a single logger and I do:
log.startLogging(...). What I need to know is how can I create three
different loggers in my new application. Do I need to subclass some
twisted class?

Chaz.

Moof wrote:
> On 6/10/06, Chaz. <eprparadocs at gmail.com> wrote:
>> I have an application that I am converting to Twisted. One of the things
>> the application does is have three different logs running. Each of the
>> three does something different.
>>
>> In normal python logging I figured out how to have the three different
>> loggers. In Twisted I am not quite sure how to do it. Has someone done
>> this before?
> 
> You want to write a class or function that will receive a dictionary
> with 'system', 'message', and possibly 'failure', 'isError', 'debug'
> and 'printed', and take appropriate action. You may wish to have a
> look at twisted.python.log.FileLogObserver. Once you have the function
> or method, you can do a log.addLogObserver(function).
> 
> You can pass things on to the eventDict as keywords to log.msg,
> log.error, and log.debug (though the last one is deprecated). If you
> find that isn't enough for you, it's possible to replace the
> LogPublisher with something that can gather more data, I currently use
> one that inspects the stack for which module called it, for example.
> 
> Moof
> 





More information about the Twisted-Python mailing list