Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save albertoalcolea/1a41d1676ae36a43ca2d to your computer and use it in GitHub Desktop.
Save albertoalcolea/1a41d1676ae36a43ca2d to your computer and use it in GitHub Desktop.
# Usage:
# MIDDLEWARE_CLASSES = (
# ...
# 'path.to.this.script.WsgiLogErrors',
#)
import traceback
class WsgiLogErrors(object):
"""
Dump django exceptions to apache (with mod_wsgi) error logs
"""
def process_exception(self, request, exception):
tb_text = traceback.format_exc()
url = request.build_absolute_uri()
request.META['wsgi.errors'].write(url + '\n' + str(tb_text) + '\n')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment