dynamically getting loggers
Gabriel Genellina
gagsl-py2 at yahoo.com.ar
Fri Aug 15 00:19:38 EDT 2008
En Thu, 14 Aug 2008 18:29:41 -0300, belred <belred at gmail.com> escribi�:
> is there a way to dynamically get all the active loggers?
>
> i currently have code like this in different areas of the program:
>
> import logging
> log = logging.getLogger('foo')
>
>
> i would like to write a function that dynamically get a list of all
> the logger names such as 'foo'. or get a list of the loggers which i
> could then get the names. is this even possible? i don't see a
> logger function that returns loggers.
Loggers are created when requested, and I don't see a documented way to
get such list.
If you don't mind using undocumented attributes:
existing_logger_names = logging.getLogger().manager.loggerDict.keys()
--
Gabriel Genellina
More information about the Python-list
mailing list