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)
{
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<Startup>()
.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.
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()

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.
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"))

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.
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")))

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.
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) =>
{