|  | dynamically getting loggers |  | |
| | | belred |  |
| Posted: Thu Aug 14, 2008 9:29 pm Post subject: dynamically getting loggers |  |
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.
thanks,
bryan |
| |
| | | Gabriel Genellina |  |
| Posted: Fri Aug 15, 2008 2:19 am Post subject: Re: dynamically getting loggers |  |
En Thu, 14 Aug 2008 18:29:41 -0300, belred <belred@gmail.com> escribi�:
| Quote: | 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 |
| |
|
|