I am trying to enable email alerts when HTTP 500 errors happens. Everything works fine, except that a Authentication credentials were not provided
(HTTP 401) error is logged at ERROR
level, which is way too verbose for email alerts.
Here is the email content (Django settings omitted here):
Report at /
[35mb'{"detail":"Authentication credentials were not provided."}' [0m
Request Method: GET
Request URL: https://myapi.org/dev/
Django Version: 2.0.2
Python Executable: /var/lang/bin/python3.6
Python Version: 3.6.1
Also, I am using the django-request-logging
module to print requests' content.
Here is my logging config:
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'formatters': {
'simple': {
'format': '%(levelname)s %(message)s'
},
},
'handlers': {
'console': {
'class': 'logging.StreamHandler',
},
'mail_admins': {
'level': 'ERROR',
'class': 'django.utils.log.AdminEmailHandler',
'email_backend': 'django.core.mail.backends.smtp.EmailBackend',
'include_html': True,
'filters': [],
'formatter': 'simple'
},
},
'loggers': {
'django.request': {
'handlers': ['console', 'mail_admins'],
'level': 'DEBUG',
'propagate': False,
},
},
}
Any idea how I could filter out HTTP 401 from the mail_admins
handler?