Author sean
Recipients sean
Date 2009-07-10.13:28:44
SpamBayes Score 0.000752088
Marked as misclassified No
Message-id <1247232526.2.0.244135072278.issue6458@psf.upfronthosting.co.za>
In-reply-to
Content
Using "logging" module I can do the following:

    f = logging.Formatter("%(levelname)s: %(name)s: %(message)s")
    h = logging.StreamHandler()
    h.setLevel(logging.NOTSET)
    h.setFormatter(f)
    l = logging.getLogger()
    l.addHandler(h)

    l2 = logging.getLogger('x.y.z')
    l2.setLevel(logging.INFO)
    print len(l2.handlers)

    l2.critical('critical')
    l2.error('error')
    l2.warning('warning')
    l2.info('info')
    l2.debug('debug')

Note, the l2(x.y.z) logger does not have a handler (it just propagates
to the l(root) logger's handler) but the l2 logger does have a different
level set.

When I try to do this with logging.config.fileConfig it fails saying I
have not specified a handler for the x.y.z logger.  But I don't want to
specify a handler, I just want to set the level and have it propagate up
the hierarchy.

Am I doing something wrong?

Sean.

P.S. Here is the config file:

[loggers]
keys=root,xyz

[handlers]
keys=consoleStderr

[formatters]
keys=simpleFormatter

[logger_root]
level=NOTSET
handlers=consoleStderr

[logger_xyz]
level=DEBUG
qualname=x.y.z

[handler_consoleStderr]
class=StreamHandler
level=NOTSET
formatter=simpleFormatter
args=(sys.stderr,)

[formatter_simpleFormatter]
%(levelname)s: %(name)s: %(message)s
History
Date User Action Args
2009-07-10 13:28:46seansetrecipients: + sean
2009-07-10 13:28:46seansetmessageid: <1247232526.2.0.244135072278.issue6458@psf.upfronthosting.co.za>
2009-07-10 13:28:44seanlinkissue6458 messages
2009-07-10 13:28:44seancreate