From a1c667c4ca2a5176c307e2835ef02281e95215de Mon Sep 17 00:00:00 2001 From: Rolf Kristensen Date: Mon, 23 Sep 2024 21:14:17 +0200 Subject: [PATCH] UseNLog should fallback after checking ContentRoot for NLog.config --- .../Extensions/ConfigureExtensions.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/NLog.Extensions.Hosting/Extensions/ConfigureExtensions.cs b/src/NLog.Extensions.Hosting/Extensions/ConfigureExtensions.cs index 002bf02e..07d3126b 100644 --- a/src/NLog.Extensions.Hosting/Extensions/ConfigureExtensions.cs +++ b/src/NLog.Extensions.Hosting/Extensions/ConfigureExtensions.cs @@ -76,15 +76,13 @@ private static void TryLoadConfigurationFromContentRootPath(LogFactory logFactor LoadXmlLoggingConfigurationFromPath(contentRootPath, $"nlog.{environmentName}.config", config.LogFactory) ?? LoadXmlLoggingConfigurationFromPath(contentRootPath, "NLog.config", config.LogFactory) ?? LoadXmlLoggingConfigurationFromPath(contentRootPath, "nlog.config", config.LogFactory); - if (nlogConfig != null) - config.Configuration = nlogConfig; + config.Configuration = nlogConfig; } else { var nlogConfig = LoadXmlLoggingConfigurationFromPath(contentRootPath, "NLog.config", config.LogFactory) ?? LoadXmlLoggingConfigurationFromPath(contentRootPath, "nlog.config", config.LogFactory); - if (nlogConfig != null) - config.Configuration = nlogConfig; + config.Configuration = nlogConfig; } }); }