From a1579f190f84798dddf92379dcbe74e235a3bb04 Mon Sep 17 00:00:00 2001 From: BrennanConroy Date: Wed, 26 Apr 2017 14:16:39 -0700 Subject: [PATCH] React to Logging API changes --- test/Microsoft.AspNetCore.Hosting.TestSites/Program.cs | 6 ++++++ .../StartupShutdown.cs | 3 --- .../WebHostBuilderTests.cs | 4 ++-- test/Microsoft.AspNetCore.Hosting.Tests/WebHostTests.cs | 5 ++++- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/test/Microsoft.AspNetCore.Hosting.TestSites/Program.cs b/test/Microsoft.AspNetCore.Hosting.TestSites/Program.cs index 57852ba997..191df6714d 100644 --- a/test/Microsoft.AspNetCore.Hosting.TestSites/Program.cs +++ b/test/Microsoft.AspNetCore.Hosting.TestSites/Program.cs @@ -7,6 +7,7 @@ using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting.Server; using Microsoft.AspNetCore.Http.Features; using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Logging; namespace ServerComparison.TestSites { @@ -21,6 +22,11 @@ namespace ServerComparison.TestSites var builder = new WebHostBuilder() .UseServer(new NoopServer()) .UseConfiguration(config) + .ConfigureLogging((_, factory) => + { + factory.AddConsole(); + factory.AddFilter("Console", level => level >= LogLevel.Warning); + }) .UseStartup("Microsoft.AspNetCore.Hosting.TestSites"); var host = builder.Build(); diff --git a/test/Microsoft.AspNetCore.Hosting.TestSites/StartupShutdown.cs b/test/Microsoft.AspNetCore.Hosting.TestSites/StartupShutdown.cs index b8a5b8b73b..7f682c7149 100644 --- a/test/Microsoft.AspNetCore.Hosting.TestSites/StartupShutdown.cs +++ b/test/Microsoft.AspNetCore.Hosting.TestSites/StartupShutdown.cs @@ -25,9 +25,6 @@ namespace Microsoft.AspNetCore.Hosting.TestSites Console.WriteLine("Stopped end"); }); - - loggerFactory.AddConsole(minLevel: LogLevel.Warning); - app.Run(context => { return context.Response.WriteAsync("Hello World"); diff --git a/test/Microsoft.AspNetCore.Hosting.Tests/WebHostBuilderTests.cs b/test/Microsoft.AspNetCore.Hosting.Tests/WebHostBuilderTests.cs index 4c5ff5b4bc..d6554024c2 100644 --- a/test/Microsoft.AspNetCore.Hosting.Tests/WebHostBuilderTests.cs +++ b/test/Microsoft.AspNetCore.Hosting.Tests/WebHostBuilderTests.cs @@ -992,7 +992,7 @@ namespace Microsoft.AspNetCore.Hosting { var provider = new TestLoggerProvider(); var builder = CreateWebHostBuilder() - .ConfigureLogging(factory => + .ConfigureLogging((_, factory) => { factory.AddProvider(provider); }) @@ -1104,7 +1104,7 @@ namespace Microsoft.AspNetCore.Hosting .UseSetting("testhostingstartup_chain", builder.GetSetting("testhostingstartup_chain") + "0") .ConfigureServices(services => services.AddSingleton()) .ConfigureServices(services => services.AddSingleton(loggerProvider.Sink)) - .ConfigureLogging(lf => lf.AddProvider(loggerProvider)) + .ConfigureLogging((_, lf) => lf.AddProvider(loggerProvider)) .ConfigureAppConfiguration((context, configurationBuilder) => configurationBuilder.AddInMemoryCollection( new [] { diff --git a/test/Microsoft.AspNetCore.Hosting.Tests/WebHostTests.cs b/test/Microsoft.AspNetCore.Hosting.Tests/WebHostTests.cs index 711512c321..10c3f8dabf 100644 --- a/test/Microsoft.AspNetCore.Hosting.Tests/WebHostTests.cs +++ b/test/Microsoft.AspNetCore.Hosting.Tests/WebHostTests.cs @@ -815,10 +815,13 @@ namespace Microsoft.AspNetCore.Hosting { var builder = CreateBuilder() .UseFakeServer() + .ConfigureLogging((_, factory) => + { + factory.AddProvider(new AllMessagesAreNeeded()); + }) .Configure( appBuilder => { - appBuilder.ApplicationServices.GetRequiredService().AddProvider(new AllMessagesAreNeeded()); appBuilder.Run(requestDelegate); }); return builder.Build();