How to make Twisted use Python logging?

前端 未结 2 509
无人共我
无人共我 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().

提交回复
热议问题