This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace StartupHelpers;
|
||||
@@ -7,12 +8,33 @@ namespace StartupHelpers;
|
||||
public static class EnvironmentDiagnostics
|
||||
{
|
||||
public static void LogEnvironmentSettings(ILogger logger, IConfiguration configuration, IWebHostEnvironment environment)
|
||||
{
|
||||
LogEnvironmentSettingsCore(logger, configuration, environment.ApplicationName, environment.EnvironmentName,
|
||||
environment.ContentRootPath, environment.WebRootPath);
|
||||
}
|
||||
|
||||
public static void LogEnvironmentSettings(ILogger logger, IConfiguration configuration, IHostEnvironment environment)
|
||||
{
|
||||
LogEnvironmentSettingsCore(logger, configuration, environment.ApplicationName, environment.EnvironmentName,
|
||||
environment.ContentRootPath, webRootPath: null);
|
||||
}
|
||||
|
||||
private static void LogEnvironmentSettingsCore(
|
||||
ILogger logger,
|
||||
IConfiguration configuration,
|
||||
string applicationName,
|
||||
string environmentName,
|
||||
string contentRootPath,
|
||||
string? webRootPath)
|
||||
{
|
||||
logger.LogInformation("==================== ENVIRONMENT SETTINGS ====================");
|
||||
logger.LogInformation("Application Name: {ApplicationName}", environment.ApplicationName);
|
||||
logger.LogInformation("Environment Name: {EnvironmentName}", environment.EnvironmentName);
|
||||
logger.LogInformation("Content Root Path: {ContentRootPath}", environment.ContentRootPath);
|
||||
logger.LogInformation("Web Root Path: {WebRootPath}", environment.WebRootPath);
|
||||
logger.LogInformation("Application Name: {ApplicationName}", applicationName);
|
||||
logger.LogInformation("Environment Name: {EnvironmentName}", environmentName);
|
||||
logger.LogInformation("Content Root Path: {ContentRootPath}", contentRootPath);
|
||||
if (!string.IsNullOrEmpty(webRootPath))
|
||||
{
|
||||
logger.LogInformation("Web Root Path: {WebRootPath}", webRootPath);
|
||||
}
|
||||
|
||||
logger.LogInformation("-------------- Environment Variables --------------");
|
||||
var envVars = Environment.GetEnvironmentVariables();
|
||||
|
||||
Reference in New Issue
Block a user