Search code examples
djangoerror-handlingmod-wsgierror-log

Django mod-wsgi error 500 - nothing useful in log files


I'm running my djnago application usind mod_wsg (I can't use built-in django server with some reasons)

When error occures and I see error 500, I'm looking for information in /var/log/apache2/errors.log , but there's no any useful information here.

If I have error with syntax or with database or in views - whatever! I'm getting error message about "UnicodeDecodeError". It looks like this:

[Mon Apr 30 00:21:48 2012] [error] [client 127.0.0.1] mod_wsgi (pid=10006): Exception occurred processing WSGI script '/hosting/mysite/public/django.wsgi'.
[Mon Apr 30 00:21:48 2012] [error] [client 127.0.0.1] Traceback (most recent call last):
[Mon Apr 30 00:21:48 2012] [error] [client 127.0.0.1]   File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/wsgi.py", line 241, in __call__
[Mon Apr 30 00:21:48 2012] [error] [client 127.0.0.1]     response = self.get_response(request)
[Mon Apr 30 00:21:48 2012] [error] [client 127.0.0.1]   File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 179, in get_response
[Mon Apr 30 00:21:48 2012] [error] [client 127.0.0.1]     response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
[Mon Apr 30 00:21:48 2012] [error] [client 127.0.0.1]   File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 221, in handle_uncaught_exception
[Mon Apr 30 00:21:48 2012] [error] [client 127.0.0.1]     return debug.technical_500_response(request, *exc_info)
[Mon Apr 30 00:21:48 2012] [error] [client 127.0.0.1]   File "/usr/local/lib/python2.7/dist-packages/django/views/debug.py", line 66, in technical_500_response
[Mon Apr 30 00:21:48 2012] [error] [client 127.0.0.1]     html = reporter.get_traceback_html()
[Mon Apr 30 00:21:48 2012] [error] [client 127.0.0.1]   File "/usr/local/lib/python2.7/dist-packages/django/views/debug.py", line 275, in get_traceback_html
[Mon Apr 30 00:21:48 2012] [error] [client 127.0.0.1]     c = Context(self.get_traceback_data())
[Mon Apr 30 00:21:48 2012] [error] [client 127.0.0.1]   File "/usr/local/lib/python2.7/dist-packages/django/views/debug.py", line 233, in get_traceback_data
[Mon Apr 30 00:21:48 2012] [error] [client 127.0.0.1]     frames = self.get_traceback_frames()
[Mon Apr 30 00:21:48 2012] [error] [client 127.0.0.1]   File "/usr/local/lib/python2.7/dist-packages/django/views/debug.py", line 387, in get_traceback_frames
[Mon Apr 30 00:21:48 2012] [error] [client 127.0.0.1]     'vars': self.filter.get_traceback_frame_variables(self.request, tb.tb_frame),
[Mon Apr 30 00:21:48 2012] [error] [client 127.0.0.1]   File "/usr/local/lib/python2.7/dist-packages/django/views/debug.py", line 183, in get_traceback_frame_variables
[Mon Apr 30 00:21:48 2012] [error] [client 127.0.0.1]     value = self.get_request_repr(value)
[Mon Apr 30 00:21:48 2012] [error] [client 127.0.0.1]   File "/usr/local/lib/python2.7/dist-packages/django/views/debug.py", line 102, in get_request_repr
[Mon Apr 30 00:21:48 2012] [error] [client 127.0.0.1]     return build_request_repr(request, POST_override=self.get_post_parameters(request))
[Mon Apr 30 00:21:48 2012] [error] [client 127.0.0.1]   File "/usr/local/lib/python2.7/dist-packages/django/http/__init__.py", line 179, in build_request_repr
[Mon Apr 30 00:21:48 2012] [error] [client 127.0.0.1]     unicode(meta)))
[Mon Apr 30 00:21:48 2012] [error] [client 127.0.0.1] UnicodeDecodeError: 'ascii' codec can't decode byte 0xd0 in position 1556: ordinal not in range(128)

I think that django tries to handle error exception and gets new error while this process. Something about encodings. But I don't know how to fix it.

How can I get information about my first error, not UnicodeDecodeError? How can I fix UnicodeDecodeError? (After fixing it I hope to see my first error description in logs).


Solution

  • Read the Django documentation where it talks about this:

    https://docs.djangoproject.com/en/dev/howto/deployment/wsgi/modwsgi/#if-you-get-a-unicodeencodeerror

    Also try setting DEBUG to True in Django settings module. It may allow the underlying error to be shown in browser. If this is a public facing site and you can't do that, then set ADMINS settings to email address as covered in Django documentation so details of errors are sent to you by email.