I have a Django project that has the following function in which I want to trigger a logger:
def remove_email_from_list(list_id, email_address):
subscriber_hash = hashlib.md5(email_clean)
url = '%s/lists/%s/members/%s' % (settings.API_URL, list_id, subscriber_hash.hexdigest())
r = requests.delete(url, auth=HTTPBasicAuth('user', settings.API_KEY),)
if r.status_code != 204:
logging.critical("Executed mailchimp api call, wrong status code. Message body = " + r.text)
return r
However, I tried all these loggers to catch this error and send an email, but somehow the logger isn't triggered. Do you guys know what I am doing wrong?
'loggers': {
'django': {
'handlers': ['mail_admins'],
'level': 'ERROR',
'propagate': True
},
'django.request': {
'handlers': ['mail_admins'],
'level': 'ERROR',
'propagate': True
},
'project_name.logging': {
'handlers': ['mail_admins'],
'level': 'ERROR',
'propagate': True,
},
'django.logging': {
'handlers': ['mail_admins'],
'level': 'ERROR',
'propagate': True,
},