diff --git a/src/Microsoft.AspNet.Hosting/Internal/HostingEngine.cs b/src/Microsoft.AspNet.Hosting/Internal/HostingEngine.cs index 556103b78a..3bdf2ade61 100644 --- a/src/Microsoft.AspNet.Hosting/Internal/HostingEngine.cs +++ b/src/Microsoft.AspNet.Hosting/Internal/HostingEngine.cs @@ -95,6 +95,7 @@ namespace Microsoft.AspNet.Hosting.Internal { var httpContext = contextFactory.CreateHttpContext(features); httpContext.ApplicationServices = _applicationServices; + var requestIdentifier = GetRequestIdentifier(httpContext); if (telemetrySource.IsEnabled("Microsoft.AspNet.Hosting.BeginRequest")) { @@ -109,7 +110,7 @@ namespace Microsoft.AspNet.Hosting.Internal logger.IsEnabled(LogLevel.Information) || logger.IsEnabled(LogLevel.Verbose) || logger.IsEnabled(LogLevel.Debug) - ? logger.BeginScope("Request Id: {RequestId}", GetRequestIdentifier(httpContext)) + ? logger.BeginScope("Request Id: {RequestId}", requestIdentifier) : null) { contextAccessor.HttpContext = httpContext;