diff --git a/core/includes/errors.inc b/core/includes/errors.inc
index 39d8ffd..8022d21 100644
--- a/core/includes/errors.inc
+++ b/core/includes/errors.inc
@@ -130,6 +130,7 @@ function _drupal_log_error($error, $fatal = FALSE) {
 
   // Backtrace array is not a valid replacement value for t().
   $backtrace = $error['backtrace'];
+  $error['@backtrace'] = Error::formatBacktrace($error['backtrace']);
   unset($error['backtrace']);
 
   // When running inside the testing framework, we relay the errors
@@ -163,18 +164,18 @@ function _drupal_log_error($error, $fatal = FALSE) {
   // installer.
   if (\Drupal::hasService('logger.factory')) {
     try {
-      \Drupal::logger('php')->log($error['severity_level'], '%type: @message in %function (line %line of %file).', $error);
+      \Drupal::logger('php')->log($error['severity_level'], '%type: @message in %function (line %line of %file) @backtrace.', $error);
     }
     catch (\Exception $e) {
       // We can't log, for example because the database connection is not
       // available. At least try to log to PHP error log.
-      error_log(strtr('Failed to log error: %type: @message in %function (line %line of %file).', $error));
+      error_log(strtr('Failed to log error: %type: @message in %function (line %line of %file). @backtrace', $error));
     }
   }
 
   // Log fatal errors, so developers can find and debug them.
   if ($fatal) {
-    error_log(sprintf('%s: %s in %s on line %d', $error['%type'], $error['@message'], $error['%file'], $error['%line']));
+    error_log(sprintf('%s: %s in %s on line %d %s', $error['%type'], $error['@message'], $error['%file'], $error['%line'], $error['@backtrace']));
   }
 
   if (PHP_SAPI === 'cli') {
diff --git a/core/modules/system/src/Tests/System/UncaughtExceptionTest.php b/core/modules/system/src/Tests/System/UncaughtExceptionTest.php
index 3a67ae8..ae534e9 100644
--- a/core/modules/system/src/Tests/System/UncaughtExceptionTest.php
+++ b/core/modules/system/src/Tests/System/UncaughtExceptionTest.php
@@ -257,7 +257,7 @@ public function testLoggerException() {
 
     // Find fatal error logged to the simpletest error.log
     $errors = file(\Drupal::root() . '/' . $this->siteDirectory . '/error.log');
-    $this->assertIdentical(count($errors), 2, 'The error + the error that the logging service is broken has been written to the error log.');
+    $this->assertIdentical(count($errors), 10, 'The error + the error that the logging service is broken has been written to the error log.');
     $this->assertTrue(strpos($errors[0], 'Failed to log error') !== FALSE, 'The error handling logs when an error could not be logged to the logger.');
 
     $expected_path = \Drupal::root() . '/core/modules/system/tests/modules/error_service_test/src/MonkeysInTheControlRoom.php';
