Bạn có thể ghi nhật ký lỗi trong chế độ xem của mình qua nhật ký trăn cũ đồng bằng. Hoặc Đặt trạng thái trên phản hồi thành 500 (giả sử chế độ xem của bạn hiện trả lại trạng thái 200 cho biết phản hồi thành công).
Edit: làm việc ví dụ
Tôi không phải là một chuyên gia về khai thác gỗ, nhưng tôi đã có ấn tượng rằng cấu hình đăng nhập của bạn trong development.ini/production.ini sẽ được nhặt, ví dụ dưới đây dường như để chứng minh rằng nhưng bạn được các thẩm phán .....
thay đổi đăng nhập cấu hình từ mặc định
[formatter_generic]
# format = %(asctime)s %(levelname)-5.5s [%(name)s][%(threadName)s] %(message)s
format = y u no work??!!?? %(message)s
# End logging configuration
quan điểm
from pyramid.view import view_config
from webob import Response
import logging
log = logging.getLogger(__name__)
@view_config(route_name='home', renderer='templates/mytemplate.pt')
def my_view(request):
raise ValueError("oops")
return {'project':'tstLogError'}
@view_config(context=Exception)
def exception_view(context, request):
log.error("The error was: %s" % context, exc_info=(context))
return Response(status_int=500, body=str(context))
from pyramid.view import view_config
from webob import Response
console đầu ra:
serving on http://0.0.0.0:6543
y u no work??!!?? The error was: oops
Traceback (most recent call last):
File "/home/twillis/projects/TestLogError/local/lib/python2.7/site-packages/pyramid/tweens.py", line 20, in excview_tween
response = handler(request)
File "/home/twillis/projects/TestLogError/local/lib/python2.7/site-packages/pyramid/router.py", line 164, in handle_request
response = view_callable(context, request)
File "/home/twillis/projects/TestLogError/local/lib/python2.7/site-packages/pyramid/config/views.py", line 333, in rendered_view
result = view(context, request)
File "/home/twillis/projects/TestLogError/local/lib/python2.7/site-packages/pyramid/config/views.py", line 471, in _requestonly_view
response = view(request)
File "/home/twillis/projects/TestLogError/tstLogError/tstlogerror/views.py", line 8, in my_view
raise ValueError("oops")
ValueError: oops
![browser screenshot](https://i.stack.imgur.com/3GHzj.png)
Nguồn
2012-03-27 13:53:31
Bạn phải tự mình đăng nhập lỗi hoặc sửa lỗi. Nếu bạn reraise lỗi nó sẽ đăng nhập nhưng sẽ không làm cho xem của bạn. Nếu bạn đăng nhập lỗi trong chế độ xem của mình, nó sẽ ghi lại và hiển thị chế độ xem của bạn. –