Serve /health and keep 404 scanner noise out of the log file

Something on the network polls /health (and /v1/models) every 30 seconds;
the former now answers 200 with a database check instead of a 404, and
django.request is limited to ERROR in the logging config so scanner 404s
stop filling backend/logs/j621.log. Real server errors still log, and the
dev server keeps printing every request to its console.
This commit is contained in:
2026-09-17 21:50:20 -05:00
parent 487d14c617
commit 38e64140ed
3 changed files with 35 additions and 0 deletions
+10
View File
@@ -238,6 +238,16 @@ LOGGING = {
},
},
"handlers": _log_handlers,
"loggers": {
# Scanners on the network probe things like /health and /v1/models;
# their 404s are noise in the log file. Real server errors (5xx) still
# log, and the dev server keeps printing every request to the console.
"django.request": {
"handlers": _root_handlers,
"level": "ERROR",
"propagate": False,
},
},
"root": {
"handlers": _root_handlers,
"level": "INFO",
+5
View File
@@ -3,6 +3,8 @@ from django.conf.urls.static import static
from django.contrib import admin
from django.urls import include, path
from apps.core.views import HealthView
urlpatterns = [
path("admin/", admin.site.urls),
path("api/auth/", include("apps.accounts.urls")),
@@ -10,6 +12,9 @@ urlpatterns = [
path("api/", include("apps.core.urls")),
path("api/", include("apps.library.urls")),
path("api/", include("apps.follows.urls")),
# Liveness probe for uptime monitors (no /api prefix, no auth).
path("health", HealthView.as_view(), name="health"),
path("health/", HealthView.as_view()),
]
if settings.DEBUG: