I have the following logging config set up in Django 1.8:
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'handlers': {
'file': {
'level': 'DEBUG',
'class': 'logging.FileHandler',
'filename': normpath(join(DJANGO_ROOT, '../../logs', 'django.log')),
},
},
'loggers': {
'': {
'handlers': ['file'],
'propagate': True,
'level': 'DEBUG',
},
},
}
Moreover, I'm also logging the stdout and stderr of gunicorn into two separate files via supervisord.
My problem is that not all errors are showing up in Django logs. For example, there is a case when I had a simple .get() query in a model's save function, which raised a DoesNotExist exception in the admin page. This exception did not show up at all in any Django log, all I could see was the 500 in the nginx log for a POST request.
When I tried with debug mode in local machine, it produced the detailed error page, but what if I couldn't reproduce a bug in a local machine?
Why are 500 errors silently disappearing in Django and how can I fix it?
// I know that Sentry is able to report such exception errors, I'm looking for a way which doesn't involve using an external service.
Reading this code from
django.core.handlers.base.BaseHandler,I see 2 possibilities :
settings.DEBUG_PROPAGATE_EXCEPTIONSisTrue'loggers': { '': { ...doesn't work for the errors catched atdjangolevel