Update – 2016
This post is still getting hits.
I recommend using one of the approaches below that use the built in logging system.
In the same way exceptions are piped to the admin email handler, you can send the data to a console logger, file logger, or anywhere else (solely, or in addition to the email handler.)
Original answer
Well, the easiest way is to set debug mode OFF and let django email you the error, since that literally takes 5 seconds:
http://docs.djangoproject.com/en/dev/howto/error-reporting/
Otherwise, I’d write a middleware that logs the exception, but it’s a little more of a pain if you want the stack trace. Here’s the documentation.
import traceback
import sys
from __future__ import print_function
class ProcessExceptionMiddleware(object):
def process_exception(self, request, exception):
# Just print the exception object to stdout
print(exception)
# Print the familiar Python-style traceback to stderr
traceback.print_exc()
# Write the traceback to a file or similar
myfile.write(''.join(traceback.format_exception(*sys.exc_info())))