From a026fc9ae6f44dc9db28c9c985e46debdb24f396 Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Thu, 13 Jul 2017 18:21:36 -0400 Subject: [PATCH] Ignore permission denied and not found errors in the middleware logger. Signed-off-by: Roberto Rosario --- mayan/apps/common/middleware/error_logging.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/mayan/apps/common/middleware/error_logging.py b/mayan/apps/common/middleware/error_logging.py index 39058af612..a90490cb5c 100644 --- a/mayan/apps/common/middleware/error_logging.py +++ b/mayan/apps/common/middleware/error_logging.py @@ -2,12 +2,17 @@ from __future__ import unicode_literals import logging +from django.core.exceptions import PermissionDenied +from django.http import Http404 + logger = logging.getLogger(__name__) class ErrorLoggingMiddleware(object): def process_exception(self, request, exception): - logger.exception( - 'Exception caught by request middleware; %s, %s', request, - exception - ) + if not isinstance(exception, (PermissionDenied, Http404)): + # Don't log non critical exceptions + logger.exception( + 'Exception caught by request middleware; %s, %s', request, + exception + )