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 Loggers 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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With