我正在使用python日志记录模块。
我使用logging.dictConfig()更新了日志配置。
我想要一种读取每个记录器使用的当前配置(例如级别)并打印它的方法。
如何获得并打印此信息?
根据Simeon的注释,logging_tree包使您可以打印出当前日志记录配置的详细信息。
>>> import logging
>>> logging.getLogger('a')
>>> logging.getLogger('a.b').setLevel(logging.DEBUG)
>>> logging.getLogger('x.c')
>>> from logging_tree import printout
>>> printout()
<--""
Level WARNING
|
o<--"a"
| Level NOTSET so inherits level WARNING
| |
| o<--"a.b"
| Level DEBUG
|
o<--[x]
|
o<--"x.c"
Level NOTSET so inherits level WARNING
>>> # Get the same display as a string:
>>> from logging_tree.format import build_description
>>> print(build_description()[:50])
<--""
Level WARNING
|
o<--"a"
| Leve
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句