logging

Baurzhan Ismagulov ibr at radix50.net
Sat Jun 3 13:04:10 CEST 2006


Hello Vinay,

On Wed, May 31, 2006 at 03:05:13PM -0700, Vinay Sajip wrote:
> > Hmm, log1 decides once whether to print an event, and after that it gets
> > printed in log1 and all its ancestors, regardless of their level? I find
> > this quite counter-intuitive. I'd instead expect that each logger
> > decides whether to print an event according to its own level. Could you
> > give an example why one would want the python behavior?
> 
> Loggers are hierarchical for a reason - not just randomly named
> channels. ...

Thanks for the explanation! Please note that I am not questioning the
usefulness of hierarchical logging -- I think it's a Good Thing. What I
can't understand is the motivation for the single place of decision
whether a message should be printed ("is enabled" in log4j terms) or
not.

Consider the following scenario: root is CRITICAL, l01 is DEBUG, a debug
message is logged on l01. l01 decides that the message should be
printed, and _both_ root and l01 print it. Now, it is good that the
message is propagated to root, but why doesn't root decide for itself
whether to print it or not?

For instance, I log root to syslog and have only critical messages
there. I log l01 to console to debug. I want that my message to l01 is
not printed by root since its level is CRITICAL. This is why I want that
each logger re-evaluates the message level for itself. Could you perhaps
give a useful example why one could want loggers to decide once?


And another thing I couldn't find how to do: I want to have several
debug levels. I can log messages without problems, but numeric values in
the configuration file cause error messages during
logging.config.fileConfig. Can I specify numeric values in the config
file?


With kind regards,
Baurzhan.



More information about the Python-list mailing list