From 89921272607f7a5ee1f4ae98572b2b6c9fffad68 Mon Sep 17 00:00:00 2001 From: Rolf Kristensen Date: Mon, 23 Sep 2024 21:38:27 +0200 Subject: [PATCH] UseNLog should fallback after checking ContentRoot for NLog.config (#765) --- .../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; } }); }