React to Logging API changes (#787)
This commit is contained in:
parent
6ab84e0f27
commit
6ff97fc83b
|
|
@ -110,10 +110,8 @@ namespace MusicStore
|
|||
});
|
||||
}
|
||||
|
||||
public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory)
|
||||
public void Configure(IApplicationBuilder app)
|
||||
{
|
||||
loggerFactory.AddConsole(minLevel: LogLevel.Warning);
|
||||
|
||||
app.UseStatusCodePagesWithRedirects("~/Home/StatusCodePage");
|
||||
|
||||
// Display custom error page in production when error occurs
|
||||
|
|
|
|||
|
|
@ -159,10 +159,8 @@ namespace MusicStore
|
|||
|
||||
}
|
||||
|
||||
public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory)
|
||||
public void Configure(IApplicationBuilder app)
|
||||
{
|
||||
loggerFactory.AddConsole(minLevel: LogLevel.Warning);
|
||||
|
||||
app.UseStatusCodePagesWithRedirects("~/Home/StatusCodePage");
|
||||
|
||||
// Error page middleware displays a nice formatted HTML page for any unhandled exceptions in the request pipeline.
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ using System.IO;
|
|||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Server.HttpSys;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace MusicStore
|
||||
{
|
||||
|
|
@ -21,11 +22,11 @@ namespace MusicStore
|
|||
.UseIISIntegration()
|
||||
.UseStartup("MusicStore");
|
||||
|
||||
if (string.Equals(builder.GetSetting("server"), "Microsoft.AspNetCore.Server.HttpSys", System.StringComparison.Ordinal))
|
||||
{
|
||||
var environment = builder.GetSetting("environment") ??
|
||||
var environment = builder.GetSetting("environment") ??
|
||||
Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");
|
||||
|
||||
if (string.Equals(builder.GetSetting("server"), "Microsoft.AspNetCore.Server.HttpSys", System.StringComparison.Ordinal))
|
||||
{
|
||||
if (string.Equals(environment, "NtlmAuthentication", System.StringComparison.Ordinal))
|
||||
{
|
||||
// Set up NTLM authentication for WebListener like below.
|
||||
|
|
@ -47,6 +48,15 @@ namespace MusicStore
|
|||
builder.UseKestrel();
|
||||
}
|
||||
|
||||
builder.ConfigureLogging(factory =>
|
||||
{
|
||||
factory.AddConsole();
|
||||
|
||||
var logLevel = string.Equals(environment, "Development", StringComparison.Ordinal) ? LogLevel.Information : LogLevel.Warning;
|
||||
|
||||
factory.AddFilter("Console", level => level >= logLevel);
|
||||
});
|
||||
|
||||
var host = builder.Build();
|
||||
|
||||
host.Run();
|
||||
|
|
|
|||
|
|
@ -131,10 +131,8 @@ namespace MusicStore
|
|||
|
||||
//This method is invoked when ASPNETCORE_ENVIRONMENT is 'Development' or is not defined
|
||||
//The allowed values are Development,Staging and Production
|
||||
public void ConfigureDevelopment(IApplicationBuilder app, ILoggerFactory loggerFactory)
|
||||
public void ConfigureDevelopment(IApplicationBuilder app)
|
||||
{
|
||||
loggerFactory.AddConsole(minLevel: LogLevel.Information);
|
||||
|
||||
// StatusCode pages to gracefully handle status codes 400-599.
|
||||
app.UseStatusCodePagesWithRedirects("~/Home/StatusCodePage");
|
||||
|
||||
|
|
@ -149,10 +147,8 @@ namespace MusicStore
|
|||
|
||||
//This method is invoked when ASPNETCORE_ENVIRONMENT is 'Staging'
|
||||
//The allowed values are Development,Staging and Production
|
||||
public void ConfigureStaging(IApplicationBuilder app, ILoggerFactory loggerFactory)
|
||||
public void ConfigureStaging(IApplicationBuilder app)
|
||||
{
|
||||
loggerFactory.AddConsole(minLevel: LogLevel.Warning);
|
||||
|
||||
// StatusCode pages to gracefully handle status codes 400-599.
|
||||
app.UseStatusCodePagesWithRedirects("~/Home/StatusCodePage");
|
||||
|
||||
|
|
@ -163,10 +159,8 @@ namespace MusicStore
|
|||
|
||||
//This method is invoked when ASPNETCORE_ENVIRONMENT is 'Production'
|
||||
//The allowed values are Development,Staging and Production
|
||||
public void ConfigureProduction(IApplicationBuilder app, ILoggerFactory loggerFactory)
|
||||
public void ConfigureProduction(IApplicationBuilder app)
|
||||
{
|
||||
loggerFactory.AddConsole(minLevel: LogLevel.Warning);
|
||||
|
||||
// StatusCode pages to gracefully handle status codes 400-599.
|
||||
app.UseStatusCodePagesWithRedirects("~/Home/StatusCodePage");
|
||||
|
||||
|
|
|
|||
|
|
@ -92,10 +92,8 @@ namespace MusicStore
|
|||
});
|
||||
}
|
||||
|
||||
public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory)
|
||||
public void Configure(IApplicationBuilder app)
|
||||
{
|
||||
loggerFactory.AddConsole(minLevel: LogLevel.Warning);
|
||||
|
||||
app.UseStatusCodePagesWithRedirects("~/Home/StatusCodePage");
|
||||
|
||||
// Error page middleware displays a nice formatted HTML page for any unhandled exceptions in the
|
||||
|
|
|
|||
|
|
@ -111,10 +111,8 @@ namespace MusicStore
|
|||
});
|
||||
}
|
||||
|
||||
public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory)
|
||||
public void Configure(IApplicationBuilder app)
|
||||
{
|
||||
loggerFactory.AddConsole(minLevel: LogLevel.Warning);
|
||||
|
||||
app.UseStatusCodePagesWithRedirects("~/Home/StatusCodePage");
|
||||
|
||||
// Display custom error page in production when error occurs
|
||||
|
|
|
|||
Loading…
Reference in New Issue