From f6ca48835a8eed176350a1afd75a542aaf73720c Mon Sep 17 00:00:00 2001 From: Nick Sweeting Date: Fri, 6 Sep 2024 02:54:53 -0700 Subject: [PATCH] hide more 404 and 304 errors from daphne logs --- archivebox/core/settings.py | 2 +- archivebox/monkey_patches.py | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/archivebox/core/settings.py b/archivebox/core/settings.py index 0a05dbd3..5a275edc 100644 --- a/archivebox/core/settings.py +++ b/archivebox/core/settings.py @@ -522,7 +522,7 @@ LOGGING = { "django.request": { # only logs 4xx and 5xx errors "propagate": False, "handlers": ["default", "logfile"], - "level": "INFO", + "level": "ERROR", "filters": ["noisyrequestsfilter"], }, "django.db.backends": { diff --git a/archivebox/monkey_patches.py b/archivebox/monkey_patches.py index 599cff00..ce137ba8 100644 --- a/archivebox/monkey_patches.py +++ b/archivebox/monkey_patches.py @@ -37,6 +37,10 @@ class ModifiedAccessLogGenerator(access.AccessLogGenerator): return if request.endswith("/favicon.ico") or request.endswith("/robots.txt") or request.endswith("/screenshot.png"): return + if request.endswith('.css') or request.endswith('.js') or request.endswith('.woff') or request.endswith('.ttf'): + return + if str(status) in ('404', '304'): + return # clean up the log format to mostly match the same format as django.conf.settings.LOGGING rich formats self.stream.write(