Finding all loggers?

Michael Hrivnak mhrivnak at hrivnak.org
Thu Jun 14 17:38:00 EDT 2012


>>> 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>}

Enjoy,
Michael

On Thu, Jun 14, 2012 at 5:03 PM, Roy Smith <roy at panix.com> wrote:
> Is there any way to get a list of all the loggers that have been
> defined?  So if somebody has done:
>
> from logging import getLogger
> getLogger("foo")
> getLogger("foo.bar")
> getLogger("baz")
>
> I want something which will give me back ["foo", "foo.bar", "baz"].
> --
> http://mail.python.org/mailman/listinfo/python-list



More information about the Python-list mailing list