Converting Python exception information to a logging string

I am trying to log exceptions in Python 2.5, but I cannot do this. All formatting functions do something else than I want.

I came up with this:

def logexception(type, value, traceback):
  print traceback.format_exception(type, value, traceback)

sys.excepthook = logexception

but it is called with an argument when called, although, according to the docs, it should work. Does anyone know what the problem is with this, or has another insertion solution?

+5
source share
2 answers

traceback format_exception , , , , , ?

, , , :

import sys
import traceback

def logexception(type, value, tb):
  print traceback.format_exception(type, value, tb)

sys.excepthook = logexception

.

+5
-1

All Articles