Created
May 5, 2014 11:28
-
-
Save albertoalcolea/1a41d1676ae36a43ca2d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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