def skip_suspicious_operations(record):
"""Prevent django from sending 500 error
email notifications for SuspiciousOperation
events, since they are not true server errors,
especially when related to the ALLOWED_HOSTS
configuration
background and more information:
http://www.tiwoc.de/blog/2013/03/django-prevent-email-notification-on-susp\
iciousoperation/
"""
if record.exc_info:
exc_value = record.exc_info[1]
if isinstance(exc_value, SuspiciousOperation):
return False
return True
# A sample logging configuration. The only tangible logging
# performed by this configuration is to send an email to
# the site admins on every HTTP 500 error.
# See http://docs.djangoproject.com/en/dev/topics/logging for
# more details on how to customize your logging configuration.
评论列表
文章目录