Logging Stacktrace To File

BW Glitch bwglitch at hotpop.com
Tue Apr 13 09:47:17 EDT 2004


Olaf Meding wrote:

>>... have to catch the exception and then log it to the file.
> 
> 
> Right.  I do also know how to open a file and write to it.
> 
> But how do I get at the stack trace?  I would like to have it look the same
> in the file as what gets printed to the screen.

The traceback module provides you with that hook. The function is 
traceback.print_exc and you can pass a file-like object in the second 
parameter.

-- 
Glitch

http://andres980.tripod.com/tf.html

"... You WIN, you depraved wad a' stinkin' slag."
"Cultivated as always, even in defeat."
         -- Rattrap and Megatron, "Fallen Comrades"



More information about the Python-list mailing list