Re: Log Exception with Backtrace

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Chris Rebert

    Re: Log Exception with Backtrace

    On Fri, Oct 17, 2008 at 9:40 AM, Heston James - Cold Beans
    <heston.james@c oldbeans.co.ukw rote:
    Afternoon Guys,
    >
    I'm currently logging exceptions within my applications like so:
    >
    try:
    #do something....
    except Exception, error:
    # Log the exception.
    self.logger.err or("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.

    Cheers,
    Chris
    --
    Follow the path of the Iguana...

Working...