From a7e412ec8037312465e3967a140a569ea63d8bd1 Mon Sep 17 00:00:00 2001 From: tiago-soczek <42525933+tiago-soczek@users.noreply.github.com> Date: Mon, 17 Sep 2018 20:01:14 -0300 Subject: [PATCH] Fix category logger for HttpsConnectionAdapter and LoggingConnectionAdapter. #2929 (#2935) --- .../Adapter/ListenOptionsConnectionLoggingExtensions.cs | 4 ++-- src/Kestrel.Core/Internal/HttpsConnectionAdapter.cs | 2 +- test/Kestrel.InMemory.FunctionalTests/HttpsTests.cs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Kestrel.Core/Adapter/ListenOptionsConnectionLoggingExtensions.cs b/src/Kestrel.Core/Adapter/ListenOptionsConnectionLoggingExtensions.cs index 11306602c6..ef95004a30 100644 --- a/src/Kestrel.Core/Adapter/ListenOptionsConnectionLoggingExtensions.cs +++ b/src/Kestrel.Core/Adapter/ListenOptionsConnectionLoggingExtensions.cs @@ -18,7 +18,7 @@ namespace Microsoft.AspNetCore.Hosting /// public static ListenOptions UseConnectionLogging(this ListenOptions listenOptions) { - return listenOptions.UseConnectionLogging(nameof(LoggingConnectionAdapter)); + return listenOptions.UseConnectionLogging(loggerName: null); } /// @@ -30,7 +30,7 @@ namespace Microsoft.AspNetCore.Hosting public static ListenOptions UseConnectionLogging(this ListenOptions listenOptions, string loggerName) { var loggerFactory = listenOptions.KestrelServerOptions.ApplicationServices.GetRequiredService(); - var logger = loggerFactory.CreateLogger(loggerName ?? nameof(LoggingConnectionAdapter)); + var logger = loggerName == null ? loggerFactory.CreateLogger() : loggerFactory.CreateLogger(loggerName); listenOptions.ConnectionAdapters.Add(new LoggingConnectionAdapter(logger)); return listenOptions; } diff --git a/src/Kestrel.Core/Internal/HttpsConnectionAdapter.cs b/src/Kestrel.Core/Internal/HttpsConnectionAdapter.cs index 28c729b8d9..e88d71c65c 100644 --- a/src/Kestrel.Core/Internal/HttpsConnectionAdapter.cs +++ b/src/Kestrel.Core/Internal/HttpsConnectionAdapter.cs @@ -61,7 +61,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Https.Internal } _options = options; - _logger = loggerFactory?.CreateLogger(nameof(HttpsConnectionAdapter)); + _logger = loggerFactory?.CreateLogger(); } public bool IsHttps => true; diff --git a/test/Kestrel.InMemory.FunctionalTests/HttpsTests.cs b/test/Kestrel.InMemory.FunctionalTests/HttpsTests.cs index 1f3039abbb..51980f6977 100644 --- a/test/Kestrel.InMemory.FunctionalTests/HttpsTests.cs +++ b/test/Kestrel.InMemory.FunctionalTests/HttpsTests.cs @@ -385,7 +385,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests public ILogger CreateLogger(string categoryName) { - if (categoryName == nameof(HttpsConnectionAdapter)) + if (categoryName == TypeNameHelper.GetTypeDisplayName(typeof(HttpsConnectionAdapter))) { return FilterLogger; }