diff --git a/lightrag/api/gunicorn_config.py b/lightrag/api/gunicorn_config.py index 0594ceae..23e46807 100644 --- a/lightrag/api/gunicorn_config.py +++ b/lightrag/api/gunicorn_config.py @@ -59,7 +59,7 @@ logconfig_dict = { }, "filters": { "path_filter": { - "()": "lightrag.api.lightrag_server.LightragPathFilter", + "()": "lightrag.utils.LightragPathFilter", }, }, "loggers": { diff --git a/lightrag/api/lightrag_server.py b/lightrag/api/lightrag_server.py index f4b21e66..24494705 100644 --- a/lightrag/api/lightrag_server.py +++ b/lightrag/api/lightrag_server.py @@ -55,41 +55,6 @@ config = configparser.ConfigParser() config.read("config.ini") -class LightragPathFilter(logging.Filter): - """Filter for lightrag logger to filter out frequent path access logs""" - - def __init__(self): - super().__init__() - # Define paths to be filtered - self.filtered_paths = ["/documents", "/health", "/webui/"] - - def filter(self, record): - try: - # Check if record has the required attributes for an access log - if not hasattr(record, "args") or not isinstance(record.args, tuple): - return True - if len(record.args) < 5: - return True - - # Extract method, path and status from the record args - method = record.args[1] - path = record.args[2] - status = record.args[4] - - # Filter out successful GET requests to filtered paths - if ( - method == "GET" - and (status == 200 or status == 304) - and path in self.filtered_paths - ): - return False - - return True - except Exception: - # In case of any error, let the message through - return True - - def create_app(args): # Setup logging logger.setLevel(args.log_level) @@ -519,7 +484,7 @@ def configure_logging(): }, "filters": { "path_filter": { - "()": "lightrag.api.lightrag_server.LightragPathFilter", + "()": "lightrag.utils.LightragPathFilter", }, }, } diff --git a/lightrag/utils.py b/lightrag/utils.py index b8f00c5d..9f751ec7 100644 --- a/lightrag/utils.py +++ b/lightrag/utils.py @@ -75,7 +75,8 @@ class LightragPathFilter(logging.Filter): def __init__(self): super().__init__() # Define paths to be filtered - self.filtered_paths = ["/documents", "/health", "/webui/"] + # self.filtered_paths = ["/documents", "/health", "/webui/"] + self.filtered_paths = ["/health", "/webui/"] def filter(self, record): try: