Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.011 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'handler': 0.05; 'subject:help': 0.08; 'falls': 0.09; 'sure)': 0.09; 'cc:addr :python-list': 0.11; 'suggest': 0.14; 'hai': 0.16; 'handlers': 0.16; 'logger': 0.16; 'logging,': 0.16; 'overriding': 0.16; 'subclassing': 0.16; 'subject:Logging': 0.16; 'exception': 0.16; 'prevent': 0.16; 'wrote:': 0.18; 'thu,': 0.19; 'aug': 0.22; 'cc:addr:python.org': 0.22; 'header:User-Agent:1': 0.23; 'skip': 0.24; 'skip:l 30': 0.24; 'file.': 0.24; 'cc:2**0': 0.24; 'source': 0.25; 'handling': 0.26; 'header:In-Reply-To:1': 0.27; "i'm": 0.30; 'file': 0.32; 'probably': 0.32; 'url:python': 0.33; "i'd": 0.34; 'could': 0.34; 'classes': 0.35; 'but': 0.35; 'there': 0.35; 'method': 0.36; 'charset:us-ascii': 0.36; 'url:org': 0.36; 'should': 0.36; 'too': 0.37; 'e.g.': 0.38; 'url:library': 0.38; 'handle': 0.38; 'anything': 0.39; 'does': 0.39; 'how': 0.40; 'simply': 0.61; "you're": 0.61; 'advanced': 0.63; 'more': 0.64; 'different': 0.65; 'levels': 0.65; 'within': 0.65; 'default': 0.69; 'each,': 0.84; '2013,': 0.91 Date: Sat, 3 Aug 2013 08:04:01 -0500 (CDT) From: Wayne Werner X-X-Sender: wayne@gilgamesh To: "Joseph L. Casale" Subject: Re: Logging help In-Reply-To: References: User-Agent: Alpine 2.02 (DEB 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: "python-list@python.org" X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 30 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1375535070 news.xs4all.nl 15893 [2001:888:2000:d::a6]:49026 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:51857 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