From aa29987be5693470b6ec5e07af4eb8e29301970a Mon Sep 17 00:00:00 2001 From: lukqw Date: Wed, 18 Feb 2026 10:12:14 +0100 Subject: [PATCH] chore(logging): enrich request handling log line with request method --- gunicorn/workers/base.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gunicorn/workers/base.py b/gunicorn/workers/base.py index ca6cf10b..5abd4d6b 100644 --- a/gunicorn/workers/base.py +++ b/gunicorn/workers/base.py @@ -257,7 +257,9 @@ class Worker: msg = "Invalid request from ip={ip}: {error}" self.log.warning(msg.format(ip=addr[0], error=str(exc))) else: - if hasattr(req, "uri"): + if hasattr(req, "uri") and hasattr(req, "method"): + self.log.exception("Error handling request %s %s", req.method, req.uri) + elif hasattr(req, "uri"): self.log.exception("Error handling request %s", req.uri) else: self.log.exception("Error handling request (no URI read)")