diff --git a/test/Microsoft.AspNetCore.SignalR.Client.FunctionalTests/HubConnectionTests.cs b/test/Microsoft.AspNetCore.SignalR.Client.FunctionalTests/HubConnectionTests.cs index 3fdd84429d..377d5d612b 100644 --- a/test/Microsoft.AspNetCore.SignalR.Client.FunctionalTests/HubConnectionTests.cs +++ b/test/Microsoft.AspNetCore.SignalR.Client.FunctionalTests/HubConnectionTests.cs @@ -12,6 +12,7 @@ using Microsoft.AspNetCore.Sockets; using Microsoft.AspNetCore.TestHost; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Logging.Console; using Xunit; namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests @@ -197,14 +198,18 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests _testServer.Dispose(); } - private static LoggerFactory CreateLogger() + private static ILoggerFactory CreateLogger() { - var loggerFactory = new LoggerFactory(); - loggerFactory.AddConsole(); - loggerFactory.AddFilter("Console", level => level >= (_verbose ? LogLevel.Trace : LogLevel.Error)); - loggerFactory.AddDebug(); + var serviceCollection = new ServiceCollection(); - return loggerFactory; + serviceCollection.AddLogging(builder => + { + builder.AddConsole(); + builder.AddFilter(level => level >= (_verbose ? LogLevel.Trace : LogLevel.Error)); + builder.AddDebug(); + }); + + return serviceCollection.BuildServiceProvider().GetRequiredService(); } public class TestHub : Hub diff --git a/test/Microsoft.AspNetCore.SignalR.Tests/ForwardingLoggerProvider.cs b/test/Microsoft.AspNetCore.SignalR.Tests/ForwardingLoggerProvider.cs new file mode 100644 index 0000000000..63c7186092 --- /dev/null +++ b/test/Microsoft.AspNetCore.SignalR.Tests/ForwardingLoggerProvider.cs @@ -0,0 +1,26 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using Microsoft.Extensions.Logging; + +namespace Microsoft.AspNetCore.SignalR.Tests +{ + internal class ForwardingLoggerProvider : ILoggerProvider + { + private readonly ILoggerFactory _loggerFactory; + + public ForwardingLoggerProvider(ILoggerFactory loggerFactory) + { + _loggerFactory = loggerFactory; + } + + public void Dispose() + { + } + + public ILogger CreateLogger(string categoryName) + { + return _loggerFactory.CreateLogger(categoryName); + } + } +} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.SignalR.Tests/ServerFixture.cs b/test/Microsoft.AspNetCore.SignalR.Tests/ServerFixture.cs index 59d86aa51f..de0f1015d0 100644 --- a/test/Microsoft.AspNetCore.SignalR.Tests/ServerFixture.cs +++ b/test/Microsoft.AspNetCore.SignalR.Tests/ServerFixture.cs @@ -54,7 +54,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests private void StartServer() { host = new WebHostBuilder() - .UseLoggerFactory(_loggerFactory) + .ConfigureLogging(builder => builder.AddProvider(new ForwardingLoggerProvider(_loggerFactory))) .UseKestrel() .UseUrls(BaseUrl) .UseContentRoot(Directory.GetCurrentDirectory()) @@ -88,5 +88,4 @@ namespace Microsoft.AspNetCore.SignalR.Tests host.Dispose(); } } - } diff --git a/test/WebSocketsTestApp/Program.cs b/test/WebSocketsTestApp/Program.cs index 8fcf453730..1ea76c4063 100644 --- a/test/WebSocketsTestApp/Program.cs +++ b/test/WebSocketsTestApp/Program.cs @@ -5,6 +5,7 @@ using System.IO; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Logging.Console; namespace WebSocketsTestApp { @@ -21,7 +22,7 @@ namespace WebSocketsTestApp .ConfigureLogging(factory => { factory.AddConsole(); - factory.AddFilter("Console", level => level >= LogLevel.Debug); + factory.AddFilter(level => level >= LogLevel.Debug); }) .UseKestrel() .UseContentRoot(Directory.GetCurrentDirectory())