This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: logging module: logger does not print log message with logging.INFO level
Type: behavior Stage:
Components: Versions: Python 3.2
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: vinay.sajip Nosy List: desbma, vinay.sajip
Priority: normal Keywords:

Created on 2012-04-09 21:51 by desbma, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (3)
msg157908 - (view) Author: desbma (desbma) * Date: 2012-04-09 21:51
The logging module does not print logging message when the logging level is set to a level inferior to the default level.
I can reproduce it using the Python3 (3.2.2) package from Ubuntu 12.04 beta2, or using a hand compiled Python 3.2.2. The bug is NOT present in Python 3.2.1.

~ $ python3
Python 3.2.3rc2 (default, Mar 21 2012, 16:59:51) 
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import logging
>>> logger = logging.getLogger()
>>> logger.getEffectiveLevel() <= logging.WARN
True
>>> logger.warn("warning message")
warning message
>>> logger.setLevel(logging.INFO)
>>> logger.getEffectiveLevel() <= logging.INFO
True
>>> logger.info("info message")
>>>
msg157938 - (view) Author: Vinay Sajip (vinay.sajip) * (Python committer) Date: 2012-04-10 07:33
You haven't configured any handlers for the logger, so by default it wouldn't actually log anything. However, when no handlers are configured, logging uses an internal "last resort" handler to print the message to sys.stderr, and this handler has a threshold of WARNING (it's meant to print stdlib warnings and errors when no handlers are configured by an application).

If you add the lines, you should see something like this:

>>> logging.basicConfig(level=logging.INFO, format='%(message)s')
>>> logging.info('info message')
info message

See

http://docs.python.org/py3k/howto/logging.html#what-happens-if-no-configuration-is-provided

for more information.
msg157992 - (view) Author: desbma (desbma) * Date: 2012-04-10 22:12
Thank you for the explanation
History
Date User Action Args
2022-04-11 14:57:29adminsetgithub: 58744
2012-04-10 22:12:37desbmasetmessages: + msg157992
2012-04-10 07:34:00vinay.sajipsetstatus: open -> closed
assignee: vinay.sajip
resolution: not a bug
messages: + msg157938
2012-04-09 21:53:48r.david.murraysetnosy: + vinay.sajip
2012-04-09 21:51:14desbmacreate