Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get uncaught exceptions to appear in the Django log

When there are uncaught exceptions in my Django project the log only shows a simple "HTTP 500" message. The HTTP response will contain the full stack trace as HTML but this is not very useful when I am developing web services not being consumed by a web browser. How can I get the full stack trace of uncaught exceptions to appear in the Django log?

I have tried installing custom middleware with a "process_exception" method and custom signals handler for the "got_request_exception" event but neither of these handlers ever got invoked.

I am using Django 1.6.1 and Tastypie 0.11.0 and I'm running in debug mode.

like image 354
Nathan Avatar asked Jan 17 '14 02:01

Nathan


1 Answers

In your django settings set:

DEBUG_PROPAGATE_EXCEPTIONS = True
TASTYPIE_FULL_DEBUG = True

Setting both of these options will allow Tastypie exceptions to propagate upwards.

https://docs.djangoproject.com/en/3.2/ref/settings/#debug-propagate-exceptions
http://django-tastypie.readthedocs.org/en/latest/settings.html#tastypie-full-debug

like image 183
bensentropy Avatar answered Nov 15 '22 01:11

bensentropy