Ah I doubted it was a bug but the behaviour surprised me. Thanks for explaining!<br><br><div class="gmail_quote">On 15 November 2012 14:56, Itamar Turner-Trauring <span dir="ltr">&lt;<a href="mailto:itamar@futurefoundries.com" target="_blank">itamar@futurefoundries.com</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br><br><div class="gmail_quote"><div>On Thu, Nov 15, 2012 at 9:02 AM, Paul Wiseman <span dir="ltr">&lt;<a href="mailto:poalman@gmail.com" target="_blank">poalman@gmail.com</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I was just looking at some logs and some of the errors logged without tracebacks, I work out it was when I wasn&#39;t passing the error object to log.err- Is this by design?<br></blockquote></div><div><br>In Python 2.x, exception objects do not have any reference to their traceback; this is one of the reasons Twisted has the Failure class, which encapsulates both. (In Python 3 exceptions do have their tracebacks attached.) Thus, if you want the traceback logged, you should do something like:<br>


<br><div style="margin-left:40px"><font face="courier new,monospace">from twisted.python import log<br><br>try:<br>    1/0<br>except Exception as e:<br>    # Log the last exception that occurred, including its traceback:<br>


    log.err(None, &quot;An error occurred.&quot;)<br></font></div> <br>Or:<br><br><div style="margin-left:40px"><font face="courier new,monospace">from twisted.python import log, failure<br><br>try:<br>    1/0<br>except Exception as e:<br>


    f = failure.Failure()<br>    log.err(f, &quot;An error occurred.&quot;)<span><font color="#888888"><br></font></span></font></div><span><font color="#888888"> <br></font></span></div></div>
<span><font color="#888888">-- <br>Itamar Turner-Trauring, Future Foundries LLC<br><a href="http://futurefoundries.com/" target="_blank">http://futurefoundries.com/</a> — Twisted consulting, training and support.<br>

<br>
</font></span><br>_______________________________________________<br>
Twisted-Python mailing list<br>
<a href="mailto:Twisted-Python@twistedmatrix.com" target="_blank">Twisted-Python@twistedmatrix.com</a><br>
<a href="http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python" target="_blank">http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python</a><br>
<br></blockquote></div><br>