New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fileConfig() disables any previously-used "named" loggers, even when getLogger() is called again. #61723
Comments
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. |
The logger obtained by logging.getLogger('root') is not the root logger, but a child of the root logger. Please post your configuration, ideally the smallest version which allows you to reproduce the failure. |
Any configuration I tried still generates the bug, but here's a pared-down config file: [loggers] [handlers] [formatters] [logger_root] [handler_screen] |
New changeset 533b4a1d2b23 by Vinay Sajip in branch '2.7': New changeset 49d54e4d95df by Vinay Sajip in branch '3.2': New changeset 1f6cda549b85 by Vinay Sajip in branch '3.3': New changeset aa01eb949636 by Vinay Sajip in branch 'default': |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: