React to Logging API changes

This commit is contained in:
BrennanConroy 2017-04-26 11:45:18 -07:00
parent 461b5976fd
commit 73a91b19a9
5 changed files with 16 additions and 13 deletions

View File

@ -23,10 +23,8 @@ namespace IISSample
public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory)
{ {
loggerfactory.AddConsole(LogLevel.Debug);
var logger = loggerfactory.CreateLogger("Requests"); var logger = loggerfactory.CreateLogger("Requests");
app.Run(async (context) => app.Run(async (context) =>
{ {
logger.LogDebug("Received request: " + context.Request.Method + " " + context.Request.Path); logger.LogDebug("Received request: " + context.Request.Method + " " + context.Request.Path);
@ -75,6 +73,11 @@ namespace IISSample
public static void Main(string[] args) public static void Main(string[] args)
{ {
var host = new WebHostBuilder() var host = new WebHostBuilder()
.ConfigureLogging((_, factory) =>
{
factory.AddConsole();
factory.AddFilter("Console", level => level >= LogLevel.Debug);
})
.UseKestrel() .UseKestrel()
.UseStartup<Startup>() .UseStartup<Startup>()
.Build(); .Build();

View File

@ -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. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Logging;
namespace TestSites namespace TestSites
{ {
@ -10,6 +11,11 @@ namespace TestSites
public static void Main(string[] args) public static void Main(string[] args)
{ {
var host = new WebHostBuilder() var host = new WebHostBuilder()
.ConfigureLogging((_, factory) =>
{
factory.AddConsole();
factory.AddFilter("Console", level => level >= LogLevel.Information);
})
.UseIISIntegration() .UseIISIntegration()
.UseStartup("TestSites") .UseStartup("TestSites")
.UseKestrel() .UseKestrel()

View File

@ -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. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Builder;
@ -11,8 +11,6 @@ namespace TestSites
{ {
public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory) public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory)
{ {
loggerFactory.AddConsole();
app.Run(ctx => app.Run(ctx =>
{ {
if (ctx.Request.Path.Value.StartsWith("/Path")) if (ctx.Request.Path.Value.StartsWith("/Path"))

View File

@ -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. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Builder;
@ -11,8 +11,6 @@ namespace TestSites
{ {
public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory) public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory)
{ {
loggerFactory.AddConsole();
app.Run(ctx => app.Run(ctx =>
{ {
if (ctx.Request.Path.Equals(new PathString("/checkclientcert"))) if (ctx.Request.Path.Equals(new PathString("/checkclientcert")))

View File

@ -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. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System; using System;
@ -15,8 +15,6 @@ namespace TestSites
{ {
public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory) public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory)
{ {
loggerFactory.AddConsole();
// Simple error page without depending on Diagnostics. // Simple error page without depending on Diagnostics.
app.Use(async (context, next) => app.Use(async (context, next) =>
{ {