diff --git a/core/lib/Drupal/Core/EventSubscriber/ExceptionLoggingSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/ExceptionLoggingSubscriber.php index 31b45d5e58aa2ed8c1e7df54523d03135fd23588..85bbe77317f65a6b80d4be6e94b1fe09cb9ea0e1 100644 --- a/core/lib/Drupal/Core/EventSubscriber/ExceptionLoggingSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/ExceptionLoggingSubscriber.php @@ -87,6 +87,7 @@ public function onClientError(ExceptionEvent $event) { $error += [ 'status_code' => $exception->getStatusCode(), ]; + unset($error['@backtrace_string']); $this->logger->get('client error') ->warning(Error::DEFAULT_ERROR_MESSAGE, $error); } diff --git a/core/tests/Drupal/KernelTests/Core/EventSubscriber/ExceptionLoggingSubscriberTest.php b/core/tests/Drupal/KernelTests/Core/EventSubscriber/ExceptionLoggingSubscriberTest.php index 9bd4d57950565f0c57624b3f5e2eef4315109c5d..63b3415a865a82098de2d1a557ba1a5cafeaaa69 100644 --- a/core/tests/Drupal/KernelTests/Core/EventSubscriber/ExceptionLoggingSubscriberTest.php +++ b/core/tests/Drupal/KernelTests/Core/EventSubscriber/ExceptionLoggingSubscriberTest.php @@ -79,6 +79,11 @@ public function testExceptionLogging() { foreach ($expected_channels as $key => $expected_channel) { $this->assertEquals($expected_channel, $logs[$key][2]['channel']); $this->assertEquals($expected_levels[$key], $logs[$key][0]); + + // Verify that @backtrace_string is removed from client error. + if ($logs[$key][2]['channel'] === 'client error') { + $this->assertArrayNotHasKey('@backtrace_string', $logs[$key][2]); + } } }