logging with logging.config.fileConfig

Jean-Michel Pichavant jeanmichel at sequans.com
Mon Feb 20 06:48:22 EST 2012


MRAB wrote:
> On 19/02/2012 20:23, Herman wrote:
>> I tried to use file to config my logger and I got a weird situation
>> that each message is outputted twice...
>> Here is my scenario:
>> python: 2.6
>>
>> file abc_logging.conf:
>>
> [snip]
>> [logger_abc]
>> level=DEBUG
>> handlers=consoleHandler
>> qualname=abc
>
> Add this line to stop the logging message from being propagated to
> higher level (ancestor) loggers:
>
> propagate=0
>
> [snip]
>>

An alternative solution is to add a handler to the root logger only. If 
you don't plan to have specific handling for the abc logger, this is the 
way to go.
Remove "handlers=consoleHandler" from abc section.

Note that %name will still properly identifies the logger that raised 
the event.

JM



More information about the Python-list mailing list