Logger / I get all messages 2 times

ASh anton.shishkov at gmail.com
Fri Oct 24 03:28:50 EDT 2008


On Oct 23, 5:10 pm, "Diez B. Roggisch" <de... at nospam.web.de> wrote:
> ASh wrote:
> > Hi,
>
> > I have this source:
>
> > import logging
> > import logging.config
>
> > logging.config.fileConfig("logging.properties")
> > log = logging.getLogger("qname")
> > log.debug("message")
>
> > ------------------- OUTPUT
> > DEBUG logger_test:8:  message
> > DEBUG logger_test:8:  message
>
> > ------- FILE CONFIG
> > [formatters]
> > keys: detailed
>
> > [handlers]
> > keys: console
>
> > [loggers]
> > keys: root, engine
>
> > [formatter_detailed]
> > format: %(levelname)s %(module)s:%(lineno)d:  %(message)s
>
> > [handler_console]
> > class: StreamHandler
> > args: []
> > formatter: detailed
>
> > [logger_root]
> > level: ERROR
> > handlers: console
>
> > [logger_engine]
> > level: DEBUG
> > qualname: qname
> > handlers: console
>
> > ---------------
>
> > Why do I get the log 2 times?
>
> Because you add the handler "console" two times, to logger_engine and
> logger_root. You should only add it to root, or set propagate to false.
>
> Diez

What if I want to output only the specific logger to console and
ignore every other?



More information about the Python-list mailing list