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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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