wsgi/web.py 浏览器中的正确错误输出

发布于 2024-10-03 21:39:11 字数 203 浏览 0 评论 0原文

我正在使用 web.py 0.3 / apache2 / mod_wsgi 并且 cgitb 模块似乎不能开箱即用(我仍然只是从 web.py 得到“内部服务器错误”并且通常的输出转到 apache 的 error_log )。 web.py 安装指南建议了一种对我不起作用的解决方法 - 我可能可以破解它使其工作,但是我应该使用更好的东西(可能是为 web.py 或 wsgi 设计的)吗?

I'm using web.py 0.3 / apache2 / mod_wsgi and the cgitb module doesn't seem to work out of the box (I still just get 'internal server error' from web.py and the usual output goes to apache's error_log). The web.py install guide suggested a workaround which didn't work for me - I could probably hack it into working, but is there something better (perhaps designed for web.py or wsgi) that I should use instead?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

丑疤怪 2024-10-10 21:39:11

在创建应用程序之前设置 web.config.debug = True。这会启用调试错误,其中包含异常的堆栈跟踪以及局部变量的值。

Set web.config.debug = True before creating your app. That enables debug error, which contains the stack trace of exception along with values of locals.

dawn曙光 2024-10-10 21:39:11

调试 apache2 和 web.py 时,通常最好在 apache 错误日志中捕获错误。例如,当您收到内部服务器错误时,这意味着您的应用程序无论出于何种原因都没有返回任何内容。

在 Linux 上,我只是在单独的终端中查看错误日志...

tail -f /var/log/apache2/error_log

或者

tail -f /var/log/httpd/error_log

其他取决于您的发行版的东西。如果存在拼写错误或错误消息或其他什么情况,即使您在浏览器中收到内部服务器错误,您也会在错误日志中看到典型的 python 堆栈跟踪。

When debugging apache2 and web.py, it's usually good to catch errors in the apache error log. When you get an internal server error, for instance, it means nothing was returned for whatever reason by your app.

On Linux, I just watch the error log in a separate terminal...

tail -f /var/log/apache2/error_log

or

tail -f /var/log/httpd/error_log

or something depending on your distribution. If there's a typo or error message or what not, you'll get the typical python stack trace in your error log even if you get an internal server error in your browser.

野侃 2024-10-10 21:39:11

缺乏 cgitb 也确实减慢了我的速度。这对我来说是这样:

尝试:
输出+=TroublesomeScript(等),

除了:
导入回溯;
Output+=str(traceback.format_exc())

如果您愿意,您可以美化输出,但这应该为您提供调试所需的信息。您也可以只输出 sys.exc_info(),但似乎建议使用回溯模块。

Lack of cgitb was really slowing me down, too. This did it for me:

try:
Output+=TroublesomeScript(etc)

except:
import traceback;
Output+=str(traceback.format_exc())

You can beautify the output if you like but this should give you the information you need for debugging. You can also just output sys.exc_info(), but the traceback module seems to be recommended.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文