Two similar logging programs but different ouputs

Vinay Sajip vinay_sajip at yahoo.co.uk
Mon Apr 18 23:55:13 CEST 2011


On Apr 18, 10:11 pm, Disc Magnet <discmag... at gmail.com> wrote:

> Could you please help me understand this difference? Programs and
> log.conf file follow:

The first program prints two messages because loggers pass events to
handlers attached to themselves and their ancestors. Hence, logger1's
message is printed by logger1's handler, and logger2's message is
printed by logger1's handler because it is an ancestor of logger2.

In the second case, logger foo.bar exists when fileConfig() is
called,  but it is not named explicitly in the configuration. Hence,
it is disabled (as documented). Hence only logger1's message is
printed.

NullHandler is a handler which does nothing - there is no point in
adding it to a system which configures logging, and only any point in
adding it to top-level loggers of libraries which may be used when
logging is configured (also documented).

Regards,

Vinay Sajip
Regards,

Vinay Sajip



More information about the Python-list mailing list