1

We use the python logging module to print required log statements and then we will debug our code.

But I want to debug the logging module itself to understand its configuration. Could you suggest if any references available to debug?

We use "logging.getLogger" to get the logger object, and it starts printing in logs when we call log.debug or log.info.

But how do I know to which file it is printing, what the available handlers are, and if its not printing some log messages, how do I know what could have happened? I want complete information of that log. Any suggestions on how to achieve this would be greatly appreciated

0

1 Answer 1

3

Use the logging_tree package to introspect the stdlib logging configuration.

Example:

>>> 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
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.