diff --git a/core/lib/Drupal/Core/Logger/LoggerChannel.php b/core/lib/Drupal/Core/Logger/LoggerChannel.php
index 9253a24..f378d15 100644
--- a/core/lib/Drupal/Core/Logger/LoggerChannel.php
+++ b/core/lib/Drupal/Core/Logger/LoggerChannel.php
@@ -110,7 +110,9 @@ public function log($level, $message, array $context = array()) {
     );
     // Some context values are only available when in a request context.
     if ($this->requestStack && $request = $this->requestStack->getCurrentRequest()) {
-      $context['request_uri'] = $request->getUri();
+      if ($request->getHost()) {
+        $context['request_uri'] = $request->getUri();
+      }
       $context['referer'] = $request->headers->get('Referer', '');
       $context['ip'] = $request->getClientIP();
       try {
diff --git a/core/tests/Drupal/Tests/Core/Logger/LoggerChannelTest.php b/core/tests/Drupal/Tests/Core/Logger/LoggerChannelTest.php
index 932edb7..fed086e 100644
--- a/core/tests/Drupal/Tests/Core/Logger/LoggerChannelTest.php
+++ b/core/tests/Drupal/Tests/Core/Logger/LoggerChannelTest.php
@@ -112,6 +112,18 @@ public function providerTestLog() {
       ->will($this->returnValue('127.0.0.1'));
     $request_mock->headers = $this->getMock('Symfony\Component\HttpFoundation\ParameterBag');
 
+    $request_mock_no_host = $this->getMock('Symfony\Component\HttpFoundation\Request');
+    $request_mock_no_host->expects($this->once())
+      ->method('getHost')
+      ->will($this->returnValue(NULL));
+    $request_mock_no_host->expects($this->once())
+      ->method('getUri')
+      ->will($this->returnValue('http://:/'));
+    $request_mock_no_host->headers = $this->getMock('Symfony\Component\HttpFoundation\ParameterBag');
+    $request_mock_no_host->headers->expects($this->once())
+      ->method('get')
+      ->will($this->returnValue('Drupal'));
+
     // No request or account.
     $cases [] = array(
       function ($context) {
@@ -127,6 +139,14 @@ function ($context) {
       NULL,
       $account_mock,
     );
+    // With request and referer but no hostname.
+    $cases [] = array(
+      function ($context) {
+        return $context['referer'] == 'Drupal' && empty($context['request_uri']);
+      },
+      $request_mock_no_host,
+      NULL,
+    );
     // With request but not account.
     $cases [] = array(
       function ($context) {
