开发者

Catching Django Errors When Client Is Not A Web Browser?

开发者 https://www.devze.com 2023-02-11 19:06 出处:网络
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 beh

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

精彩评论

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

关注公众号