Is there a way to filter out specific error messages using Django Logging? eg UncompressableFileError
Would like to stop these errors being sent to Sentry.io
CodePudding user response:
You can set a Filter
on the Sentry handler which checks for the type of errors you want to filter out, and return False
to drop them. Roughly:
def sentry_filter(record):
return 'UncompressableFileError' not in record.getMessage()
and then
sentry_handler.addFilter(sentry_filter)
This might need to be tweaked depending on where the string occurs - e.g. in message or traceback
CodePudding user response:
Found this in the end from another answer on SA which works with Raven:
class MyExceptionType(Exception):
def __init__(self, message):
super(MyExceptionType, self).__init__(message)
app = Flask(__name__)
app.config['SENTRY_CONFIG'] = {
'ignore_exceptions': [MyExceptionType],
}