Traceback in Logging

Kottiyath n.kottiyath at
Tue Jan 6 14:33:29 CET 2009

Hi all,
   Is it possible to print traceback for all logging?
   I have created something like this:

def trace():
    import traceback
    return ''.join(traceback.format_stack(limit=4)[1:])

And during every logging, append it -'Data: %s, kwargs: %s Traceback: %s' %(data,
kwargs, trace()))


2009-01-06 18:52:21,483 - test- INFO
---> Data:, kwargs: {}
Traceback:   File "C:\", line 48, in success
    super(testObj, self).success(reply, **kwargs)
  File "C:\", line 87, in success'Data: %s, kwargs: %s Traceback: %s' %(data,
kwargs, trace()))
  File "C:\", line 151, in trace
    return ''.join(traceback.format_stack(limit=4)[1:])

This seems somewhat kludgy. Is it possible in logging mechanism itself
to provide traceback as default?

I use Python2.4, so LoggingAdapter is not there too.

More information about the Python-list mailing list