【发布时间】:2019-03-26 09:51:48
【问题描述】:
我正在使用sentry-python SDK 从我的 django 服务器捕获异常。
我不想像上面那样捕获django.security.DisallowedHost。
如何删除该记录器的哨兵处理?
我在下面附上了我的服务器配置。
settings.py
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'handlers': {
'null': {
'level': 'DEBUG',
'class': 'logging.NullHandler',
},
},
'loggers': {
# Silence SuspiciousOperation.DisallowedHost exception ('Invalid
# HTTP_HOST' header messages). Set the handler to 'null' so we don't
# get those annoying emails.
'django.security.DisallowedHost': {
'handlers': ['null'],
'propagate': False,
},
}
}
sentry_sdk.init(
dsn=os.environ['SENTRY_DSN'],
integrations=[DjangoIntegration()],
send_default_pii=True,
release=f"{os.environ['STAGE']}@{os.environ['VERSION']}",
)
【问题讨论】: