Skip to content Skip to sidebar Skip to footer

Python 2 Logger Repeats Lines After Use Of Default Logger

I am working on a piece of code which instantiates its own logger with its own handlers and format. Now I've added a use of a library which uses the logging module directly and it

Solution 1:

After digging and digging, I finally found the bit of documentation that saved me!

Logger.propagate

If this evaluates to true, events logged to this logger will be passed to the handlers of higher level (ancestor) loggers, in addition to any handlers attached to this logger. Messages are passed directly to the ancestor loggers’ handlers - neither the level nor filters of the ancestor loggers in question are considered.

If this evaluates to false, logging messages are not passed to the handlers of ancestor loggers.

The constructor sets this attribute to True.

Setting log.propagate = False ended my misfortune.

It would appear that the 1st use of the default logger through logging.info has initialized the default logger and from that moment the propagation started having an effect.

Post a Comment for "Python 2 Logger Repeats Lines After Use Of Default Logger"