Hi,
I have email correctly configured in my application (using SendGrid) – it’s been working for a while to send email confirmations and so forth. I just changed my logging setup to add email notification to admins so it’s like this:
LOGGING = {
"version": 1,
"disable_existing_loggers": False,
"handlers": {
"console": {
"level": "ERROR",
"class": "logging.StreamHandler",
},
"file": {
"level": "WARNING",
"class": "logging.FileHandler",
"filename": BASE_DIR / 'debug.log',
},
"mail_admins": {
"level": "ERROR",
"class": "django.utils.log.AdminEmailHandler",
},
},
"loggers": {
"django": {
"handlers": ["file", "console", "mail_admins"],
"propagate": True,
},
},
}
I restarted the application server and forced a 500 error just now. The error was logged to the file, as usual, but I didn’t receive any email (I’m the only admin, and I checked the spam folder). I tried adding another logger to make it more like the example in the documentation, but that didn’t work either. That configuration is like this:
LOGGING = {
"version": 1,
"disable_existing_loggers": False,
"handlers": {
"console": {
"level": "ERROR",
"class": "logging.StreamHandler",
},
"file": {
"level": "WARNING",
"class": "logging.FileHandler",
"filename": BASE_DIR / 'debug.log',
},
"mail_admins": {
"level": "ERROR",
"class": "django.utils.log.AdminEmailHandler",
},
},
"loggers": {
"django": {
"handlers": ["file", "console"],
"propagate": True,
},
"django.request": {
"handlers": ["mail_admins"],
"propagate": True,
},
},
}
I’m probably missing something obvious. I’ll have a look in the source code, but I appreciate any suggestions on this!
Best,
Dow