我在Nginx后面的远程服务器上安装了Django 1.3.
如果我使用apache+mod_wsgi运行Django,我可以查看Apache日志(log)文件中的错误.可以,但我想要控制台的.
如果我运行django自己的开发服务器,只有当DEBUG=False时,控制台中的stacktrace才会出错.在调试模式下,控制台输出
Exception happened during processing of request from (..., ...)
Traceback (most recent call last):
File "/usr/local/python/lib/python2.7/SocketServer.py", line 284, in _handle_request_noblock
self.process_request(request, client_address)
File "/usr/local/python/lib/python2.7/SocketServer.py", line 310, in process_request
self.finish_request(request, client_address)
File "/usr/local/python/lib/python2.7/SocketServer.py", line 323, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "/usr/local/python/lib/python2.7/site-packages/django/core/servers/basehttp.py", line 570, in __init__
BaseHTTPRequestHandler.__init__(self, *args, **kwargs)
File "/usr/local/python/lib/python2.7/SocketServer.py", line 641, in __init__
self.finish()
File "/usr/local/python/lib/python2.7/SocketServer.py", line 694, in finish
self.wfile.flush()
File "/usr/local/python/lib/python2.7/socket.py", line 301, in flush
self._sock.sendall(view[write_offset:write_offset+buffer_size])
error: [Errno 32] Broken pipe
我想知道为什么?为什么django只输出未命名的异常?为什么它依赖于调试变量.
当我没有访问请求对象的权限时,此错误主要发生在视图外部.所以我无法在中间件或使用日志(log)处理程序中捕获它.
更新.我注意到,如果我直接向Django服务器请求,我永远不会遇到管道破裂的情况.那么这个问题会不会在Nginx代理Django的时候发生呢?