Django Error Reporting Email when Debug = True
--
Music by Eric Matyas
https://www.soundimage.org
Track title: Puzzle Game Looping
--
Chapters
00:00 Question
00:29 Accepted answer (Score 4)
01:04 Answer 2 (Score 6)
01:34 Answer 3 (Score 3)
02:02 Answer 4 (Score 2)
02:31 Thank you
--
Full question
https://stackoverflow.com/questions/6467...
Accepted answer links:
[django-sentry]: https://github.com/dcramer/django-sentry
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #django #djangoemail #djangoerrors
#avk47
ANSWER 1
Score 6
If you only have one email, make sure you have a comma in the list:
ADMINS = (('Admin', 'admin@my-domain.com'),)
I tried these and seems work:
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'handlers': {
'mail_admins': {
'level': 'ERROR',
'class': 'django.utils.log.AdminEmailHandler'
}
},
'loggers': {
'django.request': {
'handlers': ['mail_admins'],
'level': 'ERROR',
'propagate': True,
},
}
}
ACCEPTED ANSWER
Score 4
You might want to look at django-sentry. It's really designed for use in production, but it has TESTING setting to make it work when DEBUG=True as well. It might actually send out emails at that point, too -- haven't tested that myself, but it'll at least keep a log of errors that you can view at any time from any web-enabled device.
Besides, when you do eventually go to production, it'll be a life-saver.
ANSWER 3
Score 3
Just to expand on Bob Roberts answer a bit, I found the default logging configuration in django.utils.log. You can just copy and paste it to your settings, name it LOGGING, and change the line:
# settings.py:
# copied from django.utils.log import DEFAULT_LOGGING
LOGGING = {
...
'mail_admins': {
'level': 'ERROR',
# emails for all errors
#'filters': ['require_debug_false'],
'filters': [],
'class': 'django.utils.log.AdminEmailHandler'
}
...
}
ANSWER 4
Score 2
I believe you can achieve that by specifying an empty list to the filters associated with your AdminEmailHandler defined in your settings.py.
For instance:
'mail_admins': {
'level': 'ERROR',
'class': 'django.utils.log.AdminEmailHandler',
'filters': []
}
By default the filters for this class would be a django.utils.log.RequireDebugFalse.