Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #51857

Re: Logging help

Date 2013-08-03 08:04 -0500
From Wayne Werner <wayne@waynewerner.com>
Subject Re: Logging help
References <assp.0925b25cca.4de058e63b2c48468eb11a1a57210747@exch.activenetwerx.com>
Newsgroups comp.lang.python
Message-ID <mailman.154.1375535070.1251.python-list@python.org> (permalink)

Show all headers | View raw


On Thu, 1 Aug 2013, Joseph L. Casale wrote:

> I have a couple handlers applied to a logger for a file and console destination.
> Default levels have been set for each, INFO+ to console and anything to file.
>
> How does one prevent logging.exception from going to a specific handler when
> it falls within the desired levels?
>

There is probably a better way, I'm not too familiar with the more 
advanced logging, but off the top of my head I'd suggest subclassing the 
Handler classes that you're interested in and overriding the Handle method 
(I think - you can check the source to be sure) and if the type of message 
is exception then just skip handling it.

Alternatively, you could simply create a different logger, e.g.

exc_logger = logging.getLogger('mything.exceptions')


And use that to log exceptions.

Oh hai - as I was reading the documentation, look what I found:

http://docs.python.org/2/library/logging.html#filter

Methinks that should do exactly what you want.

HTH,
W

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Logging help Wayne Werner <wayne@waynewerner.com> - 2013-08-03 08:04 -0500

csiph-web