diff --git a/typo3/sysext/core/Classes/Error/AbstractExceptionHandler.php b/typo3/sysext/core/Classes/Error/AbstractExceptionHandler.php
index cbd972802d8c05d4e525db1c9443a9fa8d5adebb..53543627714fd79fcdb7b89fea41d2d12d3674b1 100644
--- a/typo3/sysext/core/Classes/Error/AbstractExceptionHandler.php
+++ b/typo3/sysext/core/Classes/Error/AbstractExceptionHandler.php
@@ -37,6 +37,8 @@ abstract class AbstractExceptionHandler implements ExceptionHandlerInterface, Si
     const CONTEXT_WEB = 'WEB';
     const CONTEXT_CLI = 'CLI';
 
+    protected $logExceptionStackTrace = false;
+
     private const IGNORED_EXCEPTION_CODES = [
         1396795884, // Current host header value does not match the configured trusted hosts pattern
         1581862822, // Failed HMAC validation due to modified __trustedProperties in extbase property mapping
@@ -88,7 +90,7 @@ abstract class AbstractExceptionHandler implements ExceptionHandlerInterface, Si
             if ($this->logger) {
                 $this->logger->critical($logTitle . ': ' . $logMessage, [
                     'TYPO3_MODE' => TYPO3_MODE,
-                    'exception' => $exception
+                    'exception' => $this->logExceptionStackTrace ? $exception : null
                 ]);
             }
             // Write error message to sys_log table
diff --git a/typo3/sysext/core/Classes/Error/DebugExceptionHandler.php b/typo3/sysext/core/Classes/Error/DebugExceptionHandler.php
index 320784c7517b8286c6999f357aefc250cc92e7ba..1bf6648ad56e574b39850a9dee87b0a79068e869 100644
--- a/typo3/sysext/core/Classes/Error/DebugExceptionHandler.php
+++ b/typo3/sysext/core/Classes/Error/DebugExceptionHandler.php
@@ -26,6 +26,8 @@ use TYPO3\CMS\Core\Information\Typo3Information;
  */
 class DebugExceptionHandler extends AbstractExceptionHandler
 {
+    protected $logExceptionStackTrace = true;
+
     /**
      * Constructs this exception handler - registers itself as the default exception handler.
      */