Re: Repeated output when logging exceptions

2009-09-30 Thread Chris Withers
John Gordon wrote: If I didn't do all that in a class, where would I do it? I find the configureLoggers method of ZConfig most convenient for this: http://pypi.python.org/pypi/ZConfig cheers, Chris -- Simplistix - Content Management, Batch Processing & Python Consulting - http://

Re: Repeated output when logging exceptions

2009-09-30 Thread Chris Withers
Vinay Sajip wrote: I'm not sure why you need all the code you've posted. The logging package allows you to add tracebacks to your logs by using the exception() method, which logs an ERROR with a traceback and is specifically intended for use from within exception handlers. You can also use the

Re: Repeated output when logging exceptions

2009-09-28 Thread Vinay Sajip
On Sep 28, 9:38 pm, John Gordon wrote: > > If I didn't do all that in a class, where would I do it? > You could, for example, use the basicConfig() function to do it all for you. import logging logging.basicConfig(filename='/path/to/my/log',level=logging.DEBUG) logging.debug('This message shoul

Re: Repeated output when logging exceptions

2009-09-28 Thread Simon Forman
On Mon, Sep 28, 2009 at 4:38 PM, John Gordon wrote: > In <6bce12c3-f2d9-450c-89ee-afa4f21d5...@h30g2000vbr.googlegroups.com> Vinay > Sajip writes: > >> The logging package allows you to add tracebacks to your logs by using >> the exception() method, which logs an ERROR with a traceback and is >>

Re: Repeated output when logging exceptions

2009-09-28 Thread John Gordon
In <6bce12c3-f2d9-450c-89ee-afa4f21d5...@h30g2000vbr.googlegroups.com> Vinay Sajip writes: > The logging package allows you to add tracebacks to your logs by using > the exception() method, which logs an ERROR with a traceback and is > specifically intended for use from within exception handlers

Re: Repeated output when logging exceptions

2009-09-25 Thread Vinay Sajip
On Sep 24, 8:43 pm, John Gordon wrote: > Why is this happening?  I suspect it's because I'm declaring two instances > of the exceptionLogger class, which ends up calling logger.addHandler() > twice.  Is that right? > Yes, that's why you get duplicated lines in the log. > What would be a better w