Extending @ dlowe's solution to Django 1.3, we can write a complete working example like:
settings.py
LOGGING = { 'version': 1, 'disable_existing_loggers': False, 'filters': { 'supress_unreadable_post': { '()': 'common.logging.SuppressUnreadablePost', } }, 'handlers': { 'mail_admins': { 'level': 'ERROR', 'class': 'django.utils.log.AdminEmailHandler', 'filters': ['supress_unreadable_post'], } }, 'loggers': { 'django.request': { 'handlers': ['mail_admins'], 'level': 'ERROR', 'propagate': True, }, } }
generic /logging.py
import sys, traceback class SuppressUnreadablePost(object): def filter(self, record): _, exception, tb = sys.exc_info() if isinstance(exception, IOError): for _, _, function, _ in traceback.extract_tb(tb): if function == '_get_raw_post_data': return False return True
Subhranath Chunder Apr 23 '12 at 16:05 2012-04-23 16:05
source share