我正在为Django项目配置错误通知。为了冗余,我想同时使用Django的AdminEmailHandler
和Airbrake(pybrake
)。
问题在于,虽然我收到Airbrake通知,但我没有收到Django错误电子邮件,其中应该包含完整的回溯。
项目有多个设置,这些设置继承自settings/base.py
,其中包含
ANYMAIL = {
"MAILGUN_API_KEY": os.getenv('MAILGUN_API_KEY'),
"MAILGUN_SENDER_DOMAIN": 'mg.startwithlucy.com',
}
EMAIL_BACKEND = "anymail.backends.mailgun.EmailBackend"
# Airbrake (pybrake) settings
AIRBRAKE = dict(
project_id=os.getenv('AIRBRAKE_PROJECT_ID'),
project_key=os.getenv('AIRBRAKE_PROJECT_KEY'),
environment=os.getenv('AIRBRAKE_ENVIRONMENT', default='production'),
root_directory=os.path.dirname(os.path.dirname(BASE_DIR)))
# Auxiliary variable used in LOGGING
_LOGGER = {
'handlers': ['airbrake', 'mail_admins'],
'level': 'ERROR',
'propagate': True,
}
# Airbrake logging integration (cf. https://github.com/airbrake/pybrake#django-integration)
# In our case, 'app' is replaced by three apps, 'lucy_web', 'api', and 'activation'.
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'handlers': {
'airbrake': {
'level': 'ERROR',
'class': 'pybrake.LoggingHandler',
},
'mail_admins': {
'level': 'ERROR',
'class': 'django.utils.log.AdminEmailHandler',
'include_html': True,
}
},
'loggers': {
'lucy_web': _LOGGER,
'api': _LOGGER,
'activation': _LOGGER,
},
}
我目前正在尝试的设置settings/staging.py
包含
import os
import anyconfig
from lucy.settings.base import *
DEBUG = False
# Set the Airbrake environment to 'staging'
AIRBRAKE.update(environment='staging')
ADDITIONAL_LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'handlers': {
'console': {
'class': 'logging.StreamHandler',
},
},
'loggers': {
# The 'django' logger is the catch-all logger for messages in the Django hierarchy
# (cf. https://docs.djangoproject.com/en/1.11/topics/logging/#django)
'django': {
'handlers': ['console'],
'level': os.getenv('LOG_LEVEL', 'INFO'),
},
},
}
# Add logging to the console to the default Airbrake logging
anyconfig.merge(self=LOGGING, other=ADDITIONAL_LOGGING)
ADMINS = [
('Kurt Peek', 'kurt@hicleo.com'),
]
我有一个测试视图,它会引发ZeroDivisionError
,我在Airbrake仪表板中看到错误:
但是,我没有收到任何电子邮件,即使配置EMAIL_BACKEND
有效。我忽略了什么?
答案 0 :(得分:0)
正如Chiefir所指出的,我确实忘记将'django'
处理程序添加到root@localhost
记录器中。
然而,SERVER_EMAIL
设置还存在另一个问题。这未指定,因此默认为ADMINS
,但Mailgun仅允许您从经过验证的域发送电子邮件。
完成这两项更改后,系统会正确收到- componentDidMount() {
-
- window.setTimeout(() => {
- const confirmButton = document.querySelector('.confirmButton');
- confirmButton && confirmButton.focus();
- }, 1);
- }
-
...
<Button
+ autofocus
的电子邮件。