Hi Patryk,

> On Feb 1, 2016, at 11:12 AM, Patryk Ściborek <pat...@sciborek.com> wrote:
> 
> On Mon, Feb 1, 2016 at 3:52 PM, Louis D. Burr <ldanielb...@me.com 
> <mailto:ldanielb...@me.com>> wrote:
> 
> Best bet is to look into the —logger parameter which you can use to pass a 
> custom logger to twistd.
> 
> Hi Daniel,
> 
> Thank you for your response. Logger option sets the name of the logger 
> factory which should create something which implements ILogObserver. But 
> still - it's part of the legacy api (twisted.python.log). I'm wondering 
> what's the right way to use new logging system here...
> 

You can most definitely use the new logging system with the —logger parameter.  
Here is an untested example:

from twisted import logger

def myLogger():
    outFile = open('/path/to/log.txt', 'w')
    observer = logger.textFileLogObserver(outFile)
    loglevel = logger.LogLevel.levelWithName('info')
    predicate = logger.LogLevelFilterPredicate()
    predicate.setLogLevelForNamespace("", loglevel)
    filter = logger.FilteringLogObserver(observer, [predicate])

    return filter
twistd [whatever] --logger=mypackage.mymodule.myLogger

Hope this helps,

Daniel
--
L. Daniel Burr
ldanielb...@me.com
(312) 656-8387
_______________________________________________
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python

Reply via email to