From 0a3c7001d4ad4b818abf0c78c96eb45ef2bc19dc Mon Sep 17 00:00:00 2001 From: BrennanConroy Date: Wed, 3 May 2017 10:39:29 -0700 Subject: [PATCH] React to Logging API changes (#433) --- .../Program.cs | 7 +++++++ .../Startup.cs | 5 +---- samples/ChatSample/Program.cs | 11 +++++++---- samples/ChatSample/Startup.cs | 6 +----- samples/SocialWeather/Program.cs | 10 ++++++---- samples/SocialWeather/Startup.cs | 4 +--- samples/SocketsSample/Program.cs | 5 +++++ samples/SocketsSample/Startup.cs | 4 +--- .../HubConnectionTests.cs | 5 +++-- test/WebSocketsTestApp/Program.cs | 6 ++++++ test/WebSocketsTestApp/Startup.cs | 2 -- 11 files changed, 38 insertions(+), 27 deletions(-) diff --git a/client-ts/Microsoft.AspNetCore.SignalR.Test.Server/Program.cs b/client-ts/Microsoft.AspNetCore.SignalR.Test.Server/Program.cs index 86618f2329..58f2bbd7d3 100644 --- a/client-ts/Microsoft.AspNetCore.SignalR.Test.Server/Program.cs +++ b/client-ts/Microsoft.AspNetCore.SignalR.Test.Server/Program.cs @@ -7,6 +7,7 @@ using System.IO; using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Logging; namespace Microsoft.AspNetCore.SignalR.Test.Server { @@ -15,6 +16,12 @@ namespace Microsoft.AspNetCore.SignalR.Test.Server public static void Main(string[] args) { var host = new WebHostBuilder() + .ConfigureLogging(factory => + { + factory.AddConsole(); + factory.AddFilter("Console", level => level >= LogLevel.Information); + factory.AddDebug(); + }) .UseKestrel() .UseContentRoot(Directory.GetCurrentDirectory()) .UseIISIntegration() diff --git a/client-ts/Microsoft.AspNetCore.SignalR.Test.Server/Startup.cs b/client-ts/Microsoft.AspNetCore.SignalR.Test.Server/Startup.cs index 50ac57fef2..9a513eacda 100644 --- a/client-ts/Microsoft.AspNetCore.SignalR.Test.Server/Startup.cs +++ b/client-ts/Microsoft.AspNetCore.SignalR.Test.Server/Startup.cs @@ -17,11 +17,8 @@ namespace Microsoft.AspNetCore.SignalR.Test.Server services.AddEndPoint(); } - public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) + public void Configure(IApplicationBuilder app, IHostingEnvironment env) { - loggerFactory.AddConsole(); - loggerFactory.AddDebug(LogLevel.Trace); - if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); diff --git a/samples/ChatSample/Program.cs b/samples/ChatSample/Program.cs index e08380975b..f6c7a1102c 100644 --- a/samples/ChatSample/Program.cs +++ b/samples/ChatSample/Program.cs @@ -1,12 +1,9 @@ // 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; -using System.Collections.Generic; using System.IO; -using System.Linq; -using System.Threading.Tasks; using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Logging; namespace ChatSample { @@ -15,6 +12,12 @@ namespace ChatSample public static void Main(string[] args) { var host = new WebHostBuilder() + .ConfigureLogging((context, factory) => + { + factory.UseConfiguration(context.Configuration.GetSection("Logging")); + factory.AddConsole(); + factory.AddDebug(); + }) .UseKestrel() .UseContentRoot(Directory.GetCurrentDirectory()) .UseIISIntegration() diff --git a/samples/ChatSample/Startup.cs b/samples/ChatSample/Startup.cs index 4e3ca6ba99..f6579bd2b7 100644 --- a/samples/ChatSample/Startup.cs +++ b/samples/ChatSample/Startup.cs @@ -11,7 +11,6 @@ using Microsoft.AspNetCore.Identity.EntityFrameworkCore; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Logging; namespace ChatSample { @@ -59,11 +58,8 @@ namespace ChatSample } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) + public void Configure(IApplicationBuilder app, IHostingEnvironment env) { - loggerFactory.AddConsole(Configuration.GetSection("Logging")); - loggerFactory.AddDebug(); - if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); diff --git a/samples/SocialWeather/Program.cs b/samples/SocialWeather/Program.cs index e55cc6444c..d25c80a04c 100644 --- a/samples/SocialWeather/Program.cs +++ b/samples/SocialWeather/Program.cs @@ -1,12 +1,9 @@ // 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; -using System.Collections.Generic; using System.IO; -using System.Linq; -using System.Threading.Tasks; using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Logging; namespace SocialWeather { @@ -15,6 +12,11 @@ namespace SocialWeather public static void Main(string[] args) { var host = new WebHostBuilder() + .ConfigureLogging(factory => + { + factory.AddConsole(); + factory.AddFilter("Console", level => level >= LogLevel.Information); + }) .UseKestrel() .UseContentRoot(Directory.GetCurrentDirectory()) .UseIISIntegration() diff --git a/samples/SocialWeather/Startup.cs b/samples/SocialWeather/Startup.cs index 05199cffb4..f7280516db 100644 --- a/samples/SocialWeather/Startup.cs +++ b/samples/SocialWeather/Startup.cs @@ -25,10 +25,8 @@ namespace SocialWeather services.AddSingleton(); } - public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) + public void Configure(IApplicationBuilder app, IHostingEnvironment env) { - loggerFactory.AddConsole(); - if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); diff --git a/samples/SocketsSample/Program.cs b/samples/SocketsSample/Program.cs index 475d8da752..5f2bafdbc4 100644 --- a/samples/SocketsSample/Program.cs +++ b/samples/SocketsSample/Program.cs @@ -4,6 +4,7 @@ using System.IO; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Logging; namespace SocketsSample { @@ -17,6 +18,10 @@ namespace SocketsSample var host = new WebHostBuilder() .UseConfiguration(config) + .ConfigureLogging(factory => + { + factory.AddConsole(); + }) .UseKestrel() .UseContentRoot(Directory.GetCurrentDirectory()) .UseIISIntegration() diff --git a/samples/SocketsSample/Startup.cs b/samples/SocketsSample/Startup.cs index 83da67ea98..b8f5f3feb4 100644 --- a/samples/SocketsSample/Startup.cs +++ b/samples/SocketsSample/Startup.cs @@ -36,10 +36,8 @@ namespace SocketsSample } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) + public void Configure(IApplicationBuilder app, IHostingEnvironment env) { - loggerFactory.AddConsole(LogLevel.Trace); - app.UseFileServer(); if (env.IsDevelopment()) diff --git a/test/Microsoft.AspNetCore.SignalR.Client.FunctionalTests/HubConnectionTests.cs b/test/Microsoft.AspNetCore.SignalR.Client.FunctionalTests/HubConnectionTests.cs index 562680f17e..51cf710546 100644 --- a/test/Microsoft.AspNetCore.SignalR.Client.FunctionalTests/HubConnectionTests.cs +++ b/test/Microsoft.AspNetCore.SignalR.Client.FunctionalTests/HubConnectionTests.cs @@ -176,8 +176,9 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests private static LoggerFactory CreateLogger() { var loggerFactory = new LoggerFactory(); - loggerFactory.AddConsole(_verbose ? LogLevel.Trace : LogLevel.Error); - loggerFactory.AddDebug(LogLevel.Trace); + loggerFactory.AddConsole(); + loggerFactory.AddFilter("Console", level => level >= (_verbose ? LogLevel.Trace : LogLevel.Error)); + loggerFactory.AddDebug(); return loggerFactory; } diff --git a/test/WebSocketsTestApp/Program.cs b/test/WebSocketsTestApp/Program.cs index c0e1548136..8fcf453730 100644 --- a/test/WebSocketsTestApp/Program.cs +++ b/test/WebSocketsTestApp/Program.cs @@ -4,6 +4,7 @@ using System.IO; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Logging; namespace WebSocketsTestApp { @@ -17,6 +18,11 @@ namespace WebSocketsTestApp var host = new WebHostBuilder() .UseConfiguration(config) + .ConfigureLogging(factory => + { + factory.AddConsole(); + factory.AddFilter("Console", level => level >= LogLevel.Debug); + }) .UseKestrel() .UseContentRoot(Directory.GetCurrentDirectory()) .UseIISIntegration() diff --git a/test/WebSocketsTestApp/Startup.cs b/test/WebSocketsTestApp/Startup.cs index d990ed1eb3..bf62e2821b 100644 --- a/test/WebSocketsTestApp/Startup.cs +++ b/test/WebSocketsTestApp/Startup.cs @@ -26,8 +26,6 @@ namespace WebSocketsTestApp // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, PipeFactory PipeFactory) { - loggerFactory.AddConsole(LogLevel.Debug); - if (env.IsDevelopment()) { app.UseDeveloperExceptionPage();