From d4084de3c1883dafec12bab681cbecd946b83786 Mon Sep 17 00:00:00 2001 From: Bernard Siebens Date: Thu, 6 Aug 2026 21:51:17 +0200 Subject: [PATCH] Log django.request errors to console in production Django's default LOGGING gates its console handler behind require_debug_true, so with DEBUG=False an unhandled exception becomes a 500 with no trace anywhere in `docker compose logs`. --- rosterchief/settings.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/rosterchief/settings.py b/rosterchief/settings.py index cd354bd..cb0a339 100644 --- a/rosterchief/settings.py +++ b/rosterchief/settings.py @@ -308,6 +308,25 @@ SECURE_HSTS_INCLUDE_SUBDOMAINS = config("DJANGO_SECURE_HSTS_INCLUDE_SUBDOMAINS", SECURE_HSTS_PRELOAD = config("DJANGO_SECURE_HSTS_PRELOAD", default=False, cast=bool) +# Logging +# +# Django's default LOGGING gates its console handler behind `require_debug_true`, so with +# DEBUG=False (every real deployment) an unhandled exception becomes a 500 response and leaves +# no trace anywhere — gunicorn's error log only sees WSGI-level crashes, not exceptions Django +# already caught and turned into a response. Without this, `docker compose logs web` is silent +# during exactly the incidents it most needs to explain. +LOGGING = { + "version": 1, + "disable_existing_loggers": False, + "handlers": { + "console": {"class": "logging.StreamHandler"}, + }, + "loggers": { + "django.request": {"handlers": ["console"], "level": "ERROR", "propagate": False}, + }, +} + + # Phone numbers (django-phonenumber-field) PHONENUMBER_DEFAULT_REGION = "BE"