Logging exceptions to a file
apt.shansen at gmail.com
Thu May 7 12:46:11 EDT 2009
> > > So far so good, but I'd like to record (possibly unhandled) exceptions
> > > in the logfile.
> > > * Do I need to explicitly trap every single exception ?
> > > * In that case, won't I get 2 log messages on the console (as
> > > illustrated in the code below:
Check out sys.excepthook, something vaguely like:
def handle_exceptions(exctype, value, traceback): logging.exception("An
unhandled exception was detected.")
sys.excepthook = handle_exceptions
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-list