gpt4 book ai didi

Django mod-wsgi 错误 500 - 日志文件中没有任何用处

转载 作者:行者123 更新时间:2023-12-03 08:59:46 24 4
gpt4 key购买 nike

我正在运行我的 djnago 应用程序使用 mod_wsg(由于某些原因,我不能使用内置的 django 服务器)

当发生错误并且我看到错误 500 时,我正在/var/log/apache2/errors.log 中查找信息,但这里没有任何有用的信息。

如果我在语法、数据库或 View 中有错误——随便!我收到有关“UnicodeDecodeError”的错误消息。它看起来像这样:

[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)

我认为 django 尝试处理错误异常并在此过程中出现新错误。关于编码的东西。但我不知道如何解决它。

如何获取关于我的第一个错误的信息,而不是 UnicodeDecodeError?
如何修复 UnicodeDecodeError? (修复它后,我希望在日志中看到我的第一个错误描述)。

最佳答案

阅读有关此内容的 Django 文档:

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

还可以尝试在 Django 设置模块中将 DEBUG 设置为 True。它可能允许在浏览器中显示底层错误。如果这是一个面向公众的站点并且您不能这样做,那么将 ADMINS 设置设置为 Django 文档中介绍的电子邮件地址,以便通过电子邮件将错误的详细信息发送给您。

关于Django mod-wsgi 错误 500 - 日志文件中没有任何用处,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10375793/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com