On 2014-12-30 18:42, jptechnical.co.uk wrote:
> I've recently started using the logging module and wondered if
> there was a way to enumerate all the Logger objects available as a
> result of calls to "logging.getLogger(name)". Went through the docs
> and could not spot any way of doing this. Have I missed something?
> 
> It would have been useful to list the Loggers created in an app as
> I'd made the mistake of writing:
> in module A:    logging.getLogger("Name")
> in module B:    logging.getLogger("name.sublogger")
> 
> and wondered why messages sent to "name.sublogger" did not get
> passed to the parent handler in "Name". A list of of available
> loggers would have quickly shown the error of my ways.

While it may involve reaching into the objects may or may not be
blessed, the following seems to work for me in Py2.7:

  >>> import logging
  >>> # add a bunch of loggers and sub-loggers
  >>> print logging.Logger.manager.loggerDict.keys()

-tkc



-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to