2

我正在运行一个 python 金字塔应用程序并对它进行安静的调用。这是一个 wsgi 应用程序,使用 waitress 作为 http 服务器。目前,当我发出失败的 http 请求时,我会收到如下消息:

Internal Server Error
The server encountered an unexpected internal server error

我将如何配置 waitress 或 paste 本身以获取显示堆栈跟踪的错误,如下所示:

Traceback (most recent call last):
  File "/.../pyramid/eggs/waitress-0.8.8-py2.7.egg/waitress/channel.py", line 337, in service
    task.service()
  File "/.../pyramid/eggs/waitress-0.8.8-py2.7.egg/waitress/task.py", line 173, in service
    self.execute()
  ...
  File "/.../pyramid/eggs/pyramid-1.4.5-py2.7.egg/pyramid/config/views.py", line 469, in _class_requestonly_view
    response = getattr(inst, attr)()
  File "/.../pyramid/dustin/views.py", line 139, in delete
    raise Exception('DELETE op failed; oid %s not found' % deleteItem)
Exception: DELETE op failed; oid 00x not found

我的贴纸配置是:

[app:main]
use = egg:myegg

pyramid.reload_templates = true
pyramid.debug_authorization = false
pyramid.debug_notfound = false
pyramid.debug_routematch = false
pyramid.debug_templates = true
pyramid.default_locale_name = es

couchdb.uri = http://couchdb-host:5984/
couchdb.db = myegg

[server:main]
use = egg:waitress#main
host = 0.0.0.0
port = 6543

# Begin logging configuration

[loggers]
keys = root

[handlers]
keys = console

[formatters]
keys = generic

[logger_root]
level = INFO
handlers = console

[handler_console]
class = StreamHandler
args = [sys.stdout]
level = DEBUG
formatter = generic

[formatter_generic]
format = %(asctime)s %(levelname)-5.5s [%(name)s][%(threadName)s] %(message)s

# End logging configuration
4

1 回答 1

1

您可以使用异常视图来捕获任何异常,并在响应中返回堆栈跟踪吗?我使用了类似的东西来捕获我所有的 Pyramid 异常,记录它们,然后向用户显示一个“友好的”错误页面渲染器。

于 2014-05-12T14:08:48.367 回答