Log Exception with Backtrace
clp at rebertia.com
Fri Oct 17 20:00:52 CEST 2008
On Fri, Oct 17, 2008 at 9:40 AM, Heston James - Cold Beans
<heston.james at coldbeans.co.uk> wrote:
> Afternoon Guys,
> I'm currently logging exceptions within my applications like so:
> #do something....
> except Exception, error:
> # Log the exception.
> self.logger.error("Exception Occurred: (%s)" % str(error))
> This is quite fine, however, sometimes I get very vague error message thrown
> at me which don't help a great deal. How can I log the full exception and
> backtrace as if it were thrown to stderr and I wasn't catching it?
Use format_exc() in the 'traceback' module to get a string for the
current stack trace (and exception) and log that.
Follow the path of the Iguana...
> Cheers all,
More information about the Python-list