开发者

Catching Django Errors When Client Is Not A Web Browser?

I'm building a Django web service that is called from an application. When it throws an exception, I can't see the Django debug page, and can't get to it because the calling application doesn't behave like a web browser (and I don't have control over that application).

Is there a way to redirect the Django error page to a a log file rather than to the calling client, possibly via changing the FastCGI config (I'm using lighty + FastCGI)? Or maybe a "dump to file" config option or some sort of LogExceptionToFile() method within the framewor开发者_C百科k itself?


You might try just creating custom ExceptionMiddleware. Just change the process_exception method to log the exception and request data somewhere.

Here's an example: http://www.peterbe.com/plog/who-was-logged-in-during-a-django-exception


If the exception in the django app is not caught, and DEBUG = True, then the exception should be sent to the client.

Some options to help you get debugging info:

  • Enable and configure logging
  • Set up email error reporting
  • Use something like Wireshark to inspect the HTTP request and responses.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜