How to make Twisted use Python logging?

前端 未结 2 496
无人共我
无人共我 2020-12-24 07:16

I\'ve got a project where I\'m using Twisted for my web server. When exceptions occur (such as network errors), it\'s printing to the console.

I\'ve already got log

相关标签:
2条回答
  • 2020-12-24 07:40

    Found it. It's actually quite easy:

    from twisted.python import log
    observer = log.PythonLoggingObserver(loggerName='logname')
    observer.start()
    

    You just set loggerName to the same logger name that you're using in logging.getLogger().

    0 讨论(0)
  • 2020-12-24 07:56

    You can use twisted.python.log. For example:

    from twisted.python import log
    log.msg('Hello, world.')
    
    0 讨论(0)
提交回复
热议问题