How do I dump the current configuration of the Python logging
module? For example, if I use a module that configures logging for me, how can I see what it has done?
There does not appear to be a documented way to do so, but we can get hints by looking at how the logging
module is implemented.
All Logger
s belong to a tree, with the root Logger
instance at logging.root
. The Logger
instances do not track their own children but instead have a shared Manager
that can be used to get a list of all loggers:
>>> print(logging.root.manager.loggerDict)
{
'rosgraph': <logging.PlaceHolder object at 0xffffa2851710>,
'rosgraph.network': <logging.Logger object at 0xffffa28517d0>,
'rosout': <rosgraph.roslogging.RospyLogger object at 0xffffa2526290>,
'rospy': <rosgraph.roslogging.RospyLogger object at 0xffffa2594250>,
...
}
Each Logger
instance has handlers
and filters
attributes which can help understand the behavior of the logger.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.