Finding All Loggers in Python
Add a commentcheat-sheet articles are about code snippets that I need every once in a while, and which I constantly forget about.
logging.Logger.manager.loggerDict
holds a dictionary of all loggers that
have been requested.
>>> import logging
>>> logging.Logger.manager.loggerDict
{}
>>> logging.getLogger('foo')
<logging.Logger object at 0x7f11d4d104d0>
>>> logging.getLogger('bar')
<logging.Logger object at 0x7f11d4cb7ad0>
>>> logging.Logger.manager.loggerDict
{'foo': <logging.Logger object at 0x7f11d4d104d0>,
'bar': <logging.Logger object at 0x7f11d4cb7ad0>}
Found at http://code.activestate.com/lists/python-list/621740/.