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

Discussion in 'Python' started by Disc Magnet, Apr 18, 2011.

  1. Disc Magnet

    Disc Magnet Guest

    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?
     
    Disc Magnet, Apr 18, 2011
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. sachin
    Replies:
    1
    Views:
    979
    Soren Kuula
    Feb 3, 2006
  2. Angel Of Death

    IsPostBack == true, even though its a callback

    Angel Of Death, Oct 25, 2006, in forum: ASP .Net
    Replies:
    4
    Views:
    485
    Flinky Wisty Pomm
    Oct 26, 2006
  3. bdb112
    Replies:
    45
    Views:
    1,377
    jazbees
    Apr 29, 2009
  4. Andy Fish
    Replies:
    1
    Views:
    224
    Andy Fish
    Oct 27, 2004
  5. cap
    Replies:
    3
    Views:
    293
    James Edward Gray II
    Dec 11, 2005
Loading...

Share This Page