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.
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:29 | admin | set | github: 58744 |
| 2012年04月10日 22:12:37 | desbma | set | messages: + msg157992 |
| 2012年04月10日 07:34:00 | vinay.sajip | set | status: open -> closed assignee: vinay.sajip resolution: not a bug messages: + msg157938 |
| 2012年04月09日 21:53:48 | r.david.murray | set | nosy:
+ vinay.sajip |
| 2012年04月09日 21:51:14 | desbma | create | |