Since the introduction of the ALLOWED_HOSTS setting in django 1.4.4, I get a lot of django error emails to my admin address for exceptions caused by some silly spider looking for vulnerable phpMyAdmin installations or somesuch. These mails are totally valid since the host headers in the spiders' requests are indeed wrong, but I'd rather have django only send me error mails when important things go wrong. Is there a simple method to silence SuspiciousOperation
mails, or do I have to go all the way and subclass CommonMiddleware
?
For completeness you can override parts of the logging: (tested on django 1.6):
LOGGING = { 'version': 1, 'disable_existing_loggers': False, 'handlers': { 'null': { 'level': 'DEBUG', 'class': 'logging.NullHandler', }, }, 'loggers': { 'django.security.DisallowedHost': { 'handlers': ['null'], 'propagate': False, }, }, }
Also see Django security docs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With