How to prevent logging warning?

Thomas Heller theller at python.net
Thu Oct 6 10:22:29 EDT 2005


"Vinay Sajip" <vinay_sajip at yahoo.co.uk> writes:

> Thomas Heller wrote:
>
>> I get the behaviour that I want when I add a 'NULL' handler in the
>> library, but is this really how logging is intended to be used?
>>
>
> The reason for the one-off message is that without it, a
> misconfiguration or a failure to configure any handlers is notified to
> a user (who is possibly not used to the logging package). I'm not sure
> which is more annoying - a one-off message which occurs when no
> handlers are configured and yet events are logged, or complete silence
> from logging when something is misconfigured, and not giving any
> feedback on what's wrong? (It's a rhetorical question - the answer is
> of course quite subjective).

I do *not* think 'no handler' is a misconfiguration. Is it possible to
differentiate between a misconfiguration and 'no configuration'?

> Certainly, I could change things so that e.g. the error is suppressed
> when logging.raiseExceptions is set to 0 (typically for production
> use).

That would be fine.  But there are also other ways - you could, for
example, print the warning only when __debug__ is False.  And you could
use the warnings module instead of blindly printing to stderr, this way
it could also be filtered out.

BTW: Since I have your attention now, is the graphical utility to
configure the logging.conf file still available somewhere, and
compatible with the current logging package (with 'current' I mean
the one included with Python 2.3.5)?

Thomas



More information about the Python-list mailing list