Is there a way to get Django to email me error reports even though I have debug set to True?
I didn't see anything in the docs.
Edit:
I'm on Django 1.2 if it matters. No, this isn't a production system.
Is there a way to get Django to email me error reports even though I have debug set to True?
I didn't see anything in the docs.
Edit:
I'm on Django 1.2 if it matters. No, this isn't a production system.
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.
If you only have one email, make sure you have a comma in the list:
ADMINS = (('Admin', '[email protected]'),)
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,
},
}
}
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.
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'
}
...
}
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.
Adding the following line to your settings.py file should do the trick.
LOGGING['handlers']['mail_admins']['filters'] = []
© 2022 - 2024 — McMap. All rights reserved.