diff --git a/jupyter_server/log.py b/jupyter_server/log.py index 3fd63c70de..0f21185b31 100644 --- a/jupyter_server/log.py +++ b/jupyter_server/log.py @@ -50,7 +50,11 @@ def log_request(handler): ns["referer"] = request.headers.get("Referer", "None") msg = msg + " referer={referer}" if status >= 500 and status != 502: - # log all headers if it caused an error - log_method(json.dumps(dict(request.headers), indent=2)) + # Log a subset of the headers if it caused an error. + headers = {} + for header in ['Host', 'Accept', 'Referer', 'User-Agent']: + if header in request.headers: + headers[header] = request.headers[header] + log_method(json.dumps(headers, indent=2)) log_method(msg.format(**ns)) prometheus_log_method(handler)