From 73a91b19a94632833f408fe943f2f35fa8ea0b59 Mon Sep 17 00:00:00 2001 From: BrennanConroy Date: Wed, 26 Apr 2017 11:45:18 -0700 Subject: [PATCH] React to Logging API changes --- samples/IISSample/Startup.cs | 9 ++++++--- test/TestSites/Program.cs | 8 +++++++- test/TestSites/StartupHelloWorld.cs | 4 +--- test/TestSites/StartupHttpsHelloWorld.cs | 4 +--- test/TestSites/StartupNtlmAuthentication.cs | 4 +--- 5 files changed, 16 insertions(+), 13 deletions(-) diff --git a/samples/IISSample/Startup.cs b/samples/IISSample/Startup.cs index 8f033dd297..7c1681eb03 100644 --- a/samples/IISSample/Startup.cs +++ b/samples/IISSample/Startup.cs @@ -23,10 +23,8 @@ namespace IISSample public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) { - loggerfactory.AddConsole(LogLevel.Debug); - var logger = loggerfactory.CreateLogger("Requests"); - + app.Run(async (context) => { logger.LogDebug("Received request: " + context.Request.Method + " " + context.Request.Path); @@ -75,6 +73,11 @@ namespace IISSample public static void Main(string[] args) { var host = new WebHostBuilder() + .ConfigureLogging((_, factory) => + { + factory.AddConsole(); + factory.AddFilter("Console", level => level >= LogLevel.Debug); + }) .UseKestrel() .UseStartup() .Build(); diff --git a/test/TestSites/Program.cs b/test/TestSites/Program.cs index 873d8d562b..04c96204ae 100644 --- a/test/TestSites/Program.cs +++ b/test/TestSites/Program.cs @@ -1,7 +1,8 @@ -// Copyright (c) .NET Foundation. All rights reserved. +// 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.AspNetCore.Hosting; +using Microsoft.Extensions.Logging; namespace TestSites { @@ -10,6 +11,11 @@ namespace TestSites public static void Main(string[] args) { var host = new WebHostBuilder() + .ConfigureLogging((_, factory) => + { + factory.AddConsole(); + factory.AddFilter("Console", level => level >= LogLevel.Information); + }) .UseIISIntegration() .UseStartup("TestSites") .UseKestrel() diff --git a/test/TestSites/StartupHelloWorld.cs b/test/TestSites/StartupHelloWorld.cs index a67a66a1ce..3d782199cd 100644 --- a/test/TestSites/StartupHelloWorld.cs +++ b/test/TestSites/StartupHelloWorld.cs @@ -1,4 +1,4 @@ -// Copyright (c) .NET Foundation. All rights reserved. +// 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.AspNetCore.Builder; @@ -11,8 +11,6 @@ namespace TestSites { public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory) { - loggerFactory.AddConsole(); - app.Run(ctx => { if (ctx.Request.Path.Value.StartsWith("/Path")) diff --git a/test/TestSites/StartupHttpsHelloWorld.cs b/test/TestSites/StartupHttpsHelloWorld.cs index 30f897e849..3d9c7a92f7 100644 --- a/test/TestSites/StartupHttpsHelloWorld.cs +++ b/test/TestSites/StartupHttpsHelloWorld.cs @@ -1,4 +1,4 @@ -// Copyright (c) .NET Foundation. All rights reserved. +// 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.AspNetCore.Builder; @@ -11,8 +11,6 @@ namespace TestSites { public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory) { - loggerFactory.AddConsole(); - app.Run(ctx => { if (ctx.Request.Path.Equals(new PathString("/checkclientcert"))) diff --git a/test/TestSites/StartupNtlmAuthentication.cs b/test/TestSites/StartupNtlmAuthentication.cs index 59a1920005..13033e7ed5 100644 --- a/test/TestSites/StartupNtlmAuthentication.cs +++ b/test/TestSites/StartupNtlmAuthentication.cs @@ -1,4 +1,4 @@ -// Copyright (c) .NET Foundation. All rights reserved. +// 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 System; @@ -15,8 +15,6 @@ namespace TestSites { public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory) { - loggerFactory.AddConsole(); - // Simple error page without depending on Diagnostics. app.Use(async (context, next) => {