[ python-Bugs-994421 ] logging module prints unexpected message when no handler set

SourceForge.net noreply at sourceforge.net
Wed Jul 21 16:24:36 CEST 2004


Bugs item #994421, was opened at 2004-07-20 10:28
Message generated for change (Comment added) made by vsajip
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=994421&group_id=5470

Category: Python Library
Group: Python 2.3
>Status: Closed
>Resolution: Invalid
Priority: 5
Submitted By: Roy Smith (roysmith)
Assigned to: Vinay Sajip (vsajip)
Summary: logging module prints unexpected message when no handler set

Initial Comment:
I am running:

Roy-Smiths-Computer:unit$ uname -a
Darwin Roy-Smiths-Computer.local 7.4.0 Darwin Kernel Version 
7.4.0: Wed May 12 16:58:24 PDT 2004; root:xnu/xnu
-517.7.7.obj~7/RELEASE_PPC  Power Macintosh powerpc
Roy-Smiths-Computer:unit$ py
Python 2.3.4 (#3, Jun 29 2004, 21:48:03) 
[GCC 3.3 20030304 (Apple Computer, Inc. build 1495)] on darwin
Type "help", "copyright", "credits" or "license" for more 
information.

---------
#!/usr/bin/env python

import logging

logger = logging.getLogger ()
logger.error ('one')
logger.error ('two')
---------

The above program prints (to stderr):

---------
No handlers could be found for logger "root"
---------

6.28 logging --  Logging facility for Python says, "Each logger can 
have zero, one or more handlers associated with it".  It doesn't 
explicitly says what happens when there are zero handlers, but I 
would expect that any messages would just be silently ignored.  
Printing a warning to stderr is definately the WRONG thing to do.


----------------------------------------------------------------------

>Comment By: Vinay Sajip (vsajip)
Date: 2004-07-21 14:24

Message:
Logged In: YES 
user_id=308438

This is not a bug. In general, the logging module does not 
print spurious error messages - however, in the case where 
no handlers are configured at all, then this is considered a 
possible configuration error and a single message is printed. 
Note that log4j does this too - it's not peculiar to Python 
logging.

Note that logged messages are not printed - only the single 
warning indicating a possible configuration problem.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=994421&group_id=5470


More information about the Python-bugs-list mailing list