Is it a bug?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Darren Cui Liang

    #1

    Is it a bug?

    Hi, there!

    Now I am working around with the "logging" module. Here is the code:

    [color=blue][color=green][color=darkred]
    >>> import logging
    >>> log1=logging.ge tLogger("a")
    >>> log1.critical(" msg")[/color][/color][/color]
    No handlers could be found for logger "a"[color=blue][color=green][color=darkred]
    >>> logging.critica l("msg")[/color][/color][/color]
    CRITICAL:root:m sg

    Since every "logger" is under the "root logger", and if no handler is
    found for the logger, the message will be passed to upper level loggers,
    until the root,
    then why do I get the msg: No handlers could be found for logger "a"

    Thanks in advance!

    BR
    Darren Cui Liang
  • Diez B. Roggisch

    #2
    Re: Is it a bug?

    Darren Cui Liang wrote:[color=blue]
    > Hi, there!
    >
    > Now I am working around with the "logging" module. Here is the code:
    >
    >[color=green][color=darkred]
    > >>> import logging
    > >>> log1=logging.ge tLogger("a")
    > >>> log1.critical(" msg")[/color][/color]
    > No handlers could be found for logger "a"[color=green][color=darkred]
    > >>> logging.critica l("msg")[/color][/color]
    > CRITICAL:root:m sg
    >
    > Since every "logger" is under the "root logger", and if no handler is
    > found for the logger, the message will be passed to upper level loggers,
    > until the root,
    > then why do I get the msg: No handlers could be found for logger "a"[/color]

    The error-message is always for the used logger - but it will search the
    list of its parents for appropriate handlers. So setting a handler on a
    logger foo makes the logger foo.bar find it. Or, alternatively, obtain a
    reference tto the root-logger, and set your handler there. Then all
    loggers will find it.

    Diez

    Comment

    Working...