From 01e2e3076702cd0a2b1dfa35f9a6fa97e4af1d37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= Date: Tue, 13 May 2025 11:18:20 +0200 Subject: [PATCH] fix(log): Only log client request id if present, and at the end MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Côme Chilliet --- lib/private/Log/LogDetails.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/private/Log/LogDetails.php b/lib/private/Log/LogDetails.php index 7406385fd58..982c1b23ac6 100644 --- a/lib/private/Log/LogDetails.php +++ b/lib/private/Log/LogDetails.php @@ -47,10 +47,8 @@ abstract class LogDetails { $userAgent = '--'; } $version = $this->config->getValue('version', ''); - $clientReqId = $request->getHeader('X-Request-Id'); $entry = compact( 'reqId', - 'clientReqId', 'level', 'time', 'remoteAddr', @@ -62,6 +60,10 @@ abstract class LogDetails { 'userAgent', 'version' ); + $clientReqId = $request->getHeader('X-Request-Id'); + if ($clientReqId !== '') { + $entry['clientReqId'] = $clientReqId; + } if (is_array($message)) { // Exception messages are extracted and the exception is put into a separate field