I have struggling with django(1.5.1) error email reports not being sent.
here is my conf settings to use with gmail
DEFAULT_FROM_EMAIL = '[email protected]'
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587
EMAIL_HOST_USER = '[email protected]'
EMAIL_HOST_PASSWORD = 'passs'
EMAIL_USE_TLS = True
SERVER_EMAIL = '[email protected]'
ADMINS = (
('Adam Min', '[email protected]'),
)
If I add MANAGERS = ADMINS
then I receive emails for 404's
but without MANAGERS
setting I receive nothing at all.
I have created a buggy url so I can test this.
Also I found this similar Q Django emailing on errors but it didn't help me.
EDIT:
also in config I have DEBUG = False
and this
LOGGING = {
'version': 1,
'disable_existing_loggers': True,
'formatters': {
'verbose': {
'format': '%(levelname)s [%(asctime)s] %(module)s %(message)s'
},
'simple': {
'format': '%(levelname)s %(message)s'
},
},
'filters': {
'require_debug_false': {
'()': 'django.utils.log.RequireDebugFalse',
}
},
'handlers': {
'console': {
'level': 'DEBUG',
'class': 'logging.StreamHandler',
'formatter': 'simple'
},
'file': {
'class': 'logging.handlers.RotatingFileHandler',
'formatter': 'verbose',
'filename': '/var/www/logs/ibiddjango.log',
'maxBytes': 1024000,
'backupCount': 3,
},
'sql': {
'class': 'logging.handlers.RotatingFileHandler',
'formatter': 'verbose',
'filename': '/var/www/logs/sql.log',
'maxBytes': 102400,
'backupCount': 3,
},
'commands': {
'class': 'logging.handlers.RotatingFileHandler',
'formatter': 'verbose',
'filename': '/var/www/logs/commands.log',
'maxBytes': 10240,
'backupCount': 3,
},
'mail_admins': {
'level': 'ERROR',
'filters': ['require_debug_false'],
'class': 'django.utils.log.AdminEmailHandler'
}
},
'loggers': {
'django': {
'handlers': ['file', 'console'],
'propagate': True,
'level': 'DEBUG',
},
'django.db.backends': {
'handlers': ['sql', 'console'],
'propagate': False,
'level': 'WARNING',
},
'scheduling': {
'handlers': ['commands', 'console'],
'propagate': True,
'level': 'DEBUG',
},
}
}
What am I missing?
it seems that your problem is in your logging configuration: in settings.py
LOGGING
:
'handlers': {
'mail_admins': {
'level': 'ERROR',
'filters': ['require_debug_false'],
'class': 'django.utils.log.AdminEmailHandler'
},
}
This config indicate that mail_admins
handler work only in DEBUG = False
because the filter used.
If you try with mode debug false or you can activate this handler in debug mode just comment the filters:
'handlers': {
'mail_admins': {
'level': 'ERROR',
#'filters': ['require_debug_false'],
'class': 'django.utils.log.AdminEmailHandler'
},
}
Edit:
Your configuration doesn't call mail_admins
handler. Add it to the django logger like this:
'loggers': {
'django': {
'handlers': ['file', 'console', 'mail_admins',],
'propagate': True,
'level': 'DEBUG',
},
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With