diff --git a/core/includes/errors.inc b/core/includes/errors.inc
index 39d8ffd..a143812 100644
--- a/core/includes/errors.inc
+++ b/core/includes/errors.inc
@@ -132,6 +132,9 @@ function _drupal_log_error($error, $fatal = FALSE) {
   $backtrace = $error['backtrace'];
   unset($error['backtrace']);
 
+  $e = new \Exception();
+  $error['@backtrace'] = $e->getTraceAsString();
+
   // When running inside the testing framework, we relay the errors
   // to the tested site by the way of HTTP headers.
   if (DRUPAL_TEST_IN_CHILD_SITE && !headers_sent() && (!defined('SIMPLETEST_COLLECT_ERRORS') || SIMPLETEST_COLLECT_ERRORS)) {
@@ -163,18 +166,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') {
