Move generic webhost log output, enable in templates (#6814)

This commit is contained in:
Chris Ross 2019-01-17 15:32:39 -08:00 committed by GitHub
parent 3dbf5d28fe
commit 9c017cd805
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 24 additions and 13 deletions

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;
@ -27,7 +27,7 @@ namespace Microsoft.AspNetCore.Hosting.Internal
{
public GenericWebHostService(IOptions<GenericWebHostServiceOptions> options,
IServer server,
ILogger<GenericWebHostService> logger,
ILoggerFactory loggerFactory,
DiagnosticListener diagnosticListener,
IHttpContextFactory httpContextFactory,
IApplicationBuilderFactory applicationBuilderFactory,
@ -37,7 +37,8 @@ namespace Microsoft.AspNetCore.Hosting.Internal
{
Options = options.Value;
Server = server;
Logger = logger;
Logger = loggerFactory.CreateLogger<GenericWebHostService>();
LifetimeLogger = loggerFactory.CreateLogger("Microsoft.Hosting.Lifetime");
DiagnosticListener = diagnosticListener;
HttpContextFactory = httpContextFactory;
ApplicationBuilderFactory = applicationBuilderFactory;
@ -49,6 +50,8 @@ namespace Microsoft.AspNetCore.Hosting.Internal
public GenericWebHostServiceOptions Options { get; }
public IServer Server { get; }
public ILogger<GenericWebHostService> Logger { get; }
// Only for high level lifetime events
public ILogger LifetimeLogger { get; }
public DiagnosticListener DiagnosticListener { get; }
public IHttpContextFactory HttpContextFactory { get; }
public IApplicationBuilderFactory ApplicationBuilderFactory { get; }
@ -119,7 +122,7 @@ namespace Microsoft.AspNetCore.Hosting.Internal
{
foreach (var address in addresses)
{
Logger.LogInformation("Now listening on: {address}", address);
LifetimeLogger.LogInformation("Now listening on: {address}", address);
}
}
@ -198,4 +201,4 @@ namespace Microsoft.AspNetCore.Hosting.Internal
}
}
}
}
}

View File

@ -1,7 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Warning"
"Default": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*"

View File

@ -1,7 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Warning"
"Default": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*"

View File

@ -1,7 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Warning"
"Default": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*"

View File

@ -33,7 +33,8 @@
//#endif
"Logging": {
"LogLevel": {
"Default": "Warning"
"Default": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*"

View File

@ -33,7 +33,8 @@
//#endif
"Logging": {
"LogLevel": {
"Default": "Warning"
"Default": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*"

View File

@ -1,7 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Warning"
"Default": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*"

View File

@ -20,7 +20,8 @@
//#endif
"Logging": {
"LogLevel": {
"Default": "Warning"
"Default": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*"

View File

@ -1,7 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Warning"
"Default": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*"