From 7e52a004999d009e3118088055e99aa35958a7fc Mon Sep 17 00:00:00 2001 From: Ben Adams Date: Sat, 26 Sep 2015 14:34:49 +0100 Subject: [PATCH] Start log scope only if logging is enabled --- src/Microsoft.AspNet.Hosting/Internal/HostingEngine.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.AspNet.Hosting/Internal/HostingEngine.cs b/src/Microsoft.AspNet.Hosting/Internal/HostingEngine.cs index 97bdc06e23..2f88460264 100644 --- a/src/Microsoft.AspNet.Hosting/Internal/HostingEngine.cs +++ b/src/Microsoft.AspNet.Hosting/Internal/HostingEngine.cs @@ -104,7 +104,9 @@ namespace Microsoft.AspNet.Hosting.Internal try { - using (logger.BeginScope("Request Id: {RequestId}", requestIdentifier)) + using (logger.IsEnabled(LogLevel.Critical) + ? logger.BeginScope("Request Id: {RequestId}", requestIdentifier) + : null) { contextAccessor.HttpContext = httpContext; await application(httpContext);