Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #51857 > unrolled thread
| Started by | Wayne Werner <wayne@waynewerner.com> |
|---|---|
| First post | 2013-08-03 08:04 -0500 |
| Last post | 2013-08-03 08:04 -0500 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: Logging help Wayne Werner <wayne@waynewerner.com> - 2013-08-03 08:04 -0500
| From | Wayne Werner <wayne@waynewerner.com> |
|---|---|
| Date | 2013-08-03 08:04 -0500 |
| Subject | Re: Logging help |
| Message-ID | <mailman.154.1375535070.1251.python-list@python.org> |
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 top | Article view | comp.lang.python
csiph-web