Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > logger warning doesn't appear even though propagate flag is True

Reply
Thread Tools

logger warning doesn't appear even though propagate flag is True

 
 
Disc Magnet
Guest
Posts: n/a
 
      04-18-2011
This program prints both the warnings:

#!/usr/bin/env python2.7

import logging
import logging.config

logging.config.fileConfig('log.conf')

log1 = logging.getLogger()
log2 = logging.getLogger('foo.bar')
log2.addHandler(logging.NullHandler())

log1.warn('warning 1')
log2.warn('warning 2')

However, this prints only the first warning:

#!/usr/bin/env python2.7

import logging
import logging.config

log2 = logging.getLogger('foo.bar')
logging.config.fileConfig('log.conf')

log1 = logging.getLogger()
log2.addHandler(logging.NullHandler())

log1.warn('warning 1')
log2.warn('warning 2')

My log.conf file is defined as:


[loggers]
keys=root

[handlers]
keys=consoleHandler

[formatters]
keys=simpleFormatter

[logger_root]
level=DEBUG
handlers=consoleHandler

[handler_consoleHandler]
class=StreamHandler
level=DEBUG
formatter=simpleFormatter
args=(sys.stdout,)

[formatter_simpleFormatter]
format=%(asctime)s %(name)s %(levelname)s - %(message)s
datefmt=%Y-%m-%d %H:%M:%S

Could you please explain why the second warning doesn't appear in the
second program?
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
CPU Usage frequently 100% even though it seems not even close tototal memory Newcomer Computer Support 3 11-15-2009 06:51 AM
CPU Usage frequently 100% even though it seems not even close tototal memory Newcomer Computer Support 0 11-14-2009 11:21 PM
[False,True] and [True,True] --> [True, True]????? bdb112 Python 45 04-29-2009 02:35 AM
IsPostBack == true, even though its a callback Angel Of Death ASP .Net 4 10-26-2006 09:56 AM
html markup allowed in textbox even though validaterequest=true Andy Fish ASP .Net Web Controls 1 10-27-2004 08:42 AM



Advertisments