Google
 
Webnews.only-4-geeks.com
Interesting places
news.only-4-geeks.com Forum Index » Python

dynamically getting loggers

 
Jump to:  
 
belred
PostPosted: 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
PostPosted: 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
 

Page 1 of 1 .:.

Google
 
Webnews.only-4-geeks.com

Windows Update | C++ | C | PHP | JavaScript | Photoshop | Programming | Windows 2000 | Python | Windows XP | Object | Flash | Flash - ActionScript | Paint Shop Pro | Excel | PowerPoint | Access | Word | Windows 98 | Internet Explorer 6.0 | CorelDraw12 | Java | XML | asm x86 | Linux Mandrake | Linux RedHat | Outlook |  | news from newsgroups |_ | s

Web Templates

Awesome Website Templates ©

Do Samotności - Mickiewicz Adam dessous bmw wrocław Krasicki Ignacy wiersze Szyba