Fix category logger for HttpsConnectionAdapter and LoggingConnectionAdapter. #2929 (#2935)

This commit is contained in:
tiago-soczek 2018-09-17 20:01:14 -03:00 committed by Chris Ross
parent b8423b8530
commit a7e412ec80
3 changed files with 4 additions and 4 deletions

View File

@ -18,7 +18,7 @@ namespace Microsoft.AspNetCore.Hosting
/// </returns> /// </returns>
public static ListenOptions UseConnectionLogging(this ListenOptions listenOptions) public static ListenOptions UseConnectionLogging(this ListenOptions listenOptions)
{ {
return listenOptions.UseConnectionLogging(nameof(LoggingConnectionAdapter)); return listenOptions.UseConnectionLogging(loggerName: null);
} }
/// <summary> /// <summary>
@ -30,7 +30,7 @@ namespace Microsoft.AspNetCore.Hosting
public static ListenOptions UseConnectionLogging(this ListenOptions listenOptions, string loggerName) public static ListenOptions UseConnectionLogging(this ListenOptions listenOptions, string loggerName)
{ {
var loggerFactory = listenOptions.KestrelServerOptions.ApplicationServices.GetRequiredService<ILoggerFactory>(); var loggerFactory = listenOptions.KestrelServerOptions.ApplicationServices.GetRequiredService<ILoggerFactory>();
var logger = loggerFactory.CreateLogger(loggerName ?? nameof(LoggingConnectionAdapter)); var logger = loggerName == null ? loggerFactory.CreateLogger<LoggingConnectionAdapter>() : loggerFactory.CreateLogger(loggerName);
listenOptions.ConnectionAdapters.Add(new LoggingConnectionAdapter(logger)); listenOptions.ConnectionAdapters.Add(new LoggingConnectionAdapter(logger));
return listenOptions; return listenOptions;
} }

View File

@ -61,7 +61,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Https.Internal
} }
_options = options; _options = options;
_logger = loggerFactory?.CreateLogger(nameof(HttpsConnectionAdapter)); _logger = loggerFactory?.CreateLogger<HttpsConnectionAdapter>();
} }
public bool IsHttps => true; public bool IsHttps => true;

View File

@ -385,7 +385,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
public ILogger CreateLogger(string categoryName) public ILogger CreateLogger(string categoryName)
{ {
if (categoryName == nameof(HttpsConnectionAdapter)) if (categoryName == TypeNameHelper.GetTypeDisplayName(typeof(HttpsConnectionAdapter)))
{ {
return FilterLogger; return FilterLogger;
} }