如何使用 Apache + mod_python + Django 跟踪 500 个服务器错误?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2036260/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do you trace 500 server errors with Apache + mod_python + Django?
提问by Andrew C
Possible Duplicate:
Django Unhandled Exception
可能的重复:
Django 未处理的异常
I'm randomly getting 500 server errors and trying to diagnose the problem. The setup is:
我随机收到 500 个服务器错误并尝试诊断问题。设置是:
Apache + mod_python + Django
Apache + mod_python + Django
My 500.html page is being served by Django, but I have no clue what is causing the error. My Apache access.log and error.log files don't contain any valuable debugging info, besides showing the request returned a 500.
我的 500.html 页面由 Django 提供服务,但我不知道是什么导致了错误。除了显示请求返回 500 之外,我的 Apache access.log 和 error.log 文件不包含任何有价值的调试信息。
Is there a mod_python or general python error log somewhere (Ubuntu server)?
某处(Ubuntu 服务器)是否有 mod_python 或通用 python 错误日志?
Thanks!
谢谢!
回答by JAL
Yes, you should have an entry in your apache confs as to where the error log is for the virtual server. For instance the name of my virtual server is djangoserver, and in my /etc/apache2/sites-enabled/djangoserver file is the line
是的,您应该在 apache confs 中有一个条目,说明虚拟服务器的错误日志在哪里。例如,我的虚拟服务器的名称是 djangoserver,在我的 /etc/apache2/sites-enabled/djangoserver 文件中是一行
ErrorLog /var/log/apache2/djangoserver-errors.log
Although now that I reread your question, it appears you already have the apache log taken care of. I don't believe there is any separate log for mod_python or python itself.
尽管现在我重读了您的问题,但您似乎已经处理了 apache 日志。我不相信 mod_python 或 python 本身有任何单独的日志。
Is this a production set up?
这是制作组吗?
If not you might wish to turn on Debug mode, and then Django produces very detailed screens with the error information. In your project's settings.py, set
如果不是,您可能希望打开Debug mode,然后 Django 会生成带有错误信息的非常详细的屏幕。在您项目的 settings.py 中,设置
DEBUG = True
TEMPLATE_DEBUG = DEBUG
to disable the generic 500 error screens and see the detailed breakdown.
禁用通用 500 错误屏幕并查看详细分类。
回答by Peter Rowell
Salsa makes several good suggestions. I would add that the Django development server is an excellent environment for tracking these things down. Sometimes I even run it from the production directory (gasp!) with ./manage.py runserver 0.0.0.0:8000so I knowI'm running the same code.
Salsa 提出了几个很好的建议。我想补充一点,Django 开发服务器是跟踪这些事情的绝佳环境。有时我什至从生产目录(喘气!)运行它,./manage.py runserver 0.0.0.0:8000所以我知道我正在运行相同的代码。
Admittedly sometimes something will fail under Apache and not under the dev server, but that is a hint in and of itself.
诚然,有时某些事情会在 Apache 下而不是在开发服务器下失败,但这本身就是一个提示。

