New submission from Bob Igo:

I am aware of the described behavior of fileConfig() when 
disable_existing_loggers is True, but what I am seeing happens whether 
disable_existing_loggers is True or False, and it also affects loggers obtained 
via future, fresh calls to getLogger(name).

Here's an example where disable_existing_loggers is True, but as I said, the 
same happens when it's False:

>>> import logging.config
>>> logging.config.fileConfig('unit_test_logging.conf')
>>> logger = logging.getLogger("foo")
>>> logger.critical("test")
2013-03-21 23:33:04,621    foo    CRITICAL    test
>>> logging.config.fileConfig('unit_test_logging.conf')
>>> logger = logging.getLogger("foo")
>>> logger.critical("test")
>>>

Note that the final logging attempt silently fails. The thing that appears to 
break logging for ever is the second fileConfig() call, and not the following 
getLogger() call.

I can get a fresh logger with a different name and use it. (Continued from the 
above session):

>>> logger = logging.getLogger("bar")
>>> logger.critical("test")
2013-03-21 23:38:35,613    bar    CRITICAL    test


This issue does not affect the root logger, when no name is given to 
getLogger():

>>> import logging.config
>>> logging.config.fileConfig('unit_test_logging.conf')
>>> logger = logging.getLogger()
>>> logger.critical("test")
2013-03-22 11:49:29,957    root    CRITICAL    test
>>> logging.config.fileConfig('unit_test_logging.conf')
>>> logger = logging.getLogger()
>>> logger.critical("test")
2013-03-22 11:49:44,966    root    CRITICAL    test


However, it _does_ affect the root logger when "root" is given as the name to 
getLogger():

>>> import logging.config
>>> logging.config.fileConfig('unit_test_logging.conf')
>>> logger = logging.getLogger("root")
>>> logger.critical("test")
2013-03-22 12:42:49,742 root    CRITICAL        test
>>> logging.config.fileConfig('unit_test_logging.conf')
>>> logger = logging.getLogger("root")
>>> logger.critical("test")
>>> 

I can attach the logging config file if desired, but it looks like the issue is 
unrelated. I will say that I'm relying on the root logger for all my logging, 
but that I use a different name to differentiate how the log is written.

----------
components: Library (Lib)
messages: 184982
nosy: Bob.Igo
priority: normal
severity: normal
status: open
title: fileConfig() disables any previously-used "named" loggers, even when 
getLogger() is called again.
type: behavior
versions: Python 2.7

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue17521>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to