Skip to content

Commit 2f8a738

Browse files
committed
Fix NLogLoggingConfiguration to handle throwConfigExceptions with NLog 5.0 (#531)
1 parent e2bffa9 commit 2f8a738

2 files changed

Lines changed: 2 additions & 1 deletion

File tree

src/NLog.Extensions.Logging/Config/NLogLoggingConfiguration.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ private IEnumerable<KeyValuePair<string, string>> GetValues()
175175
{
176176
yield return new KeyValuePair<string, string>("type", GetConfigKey(_configurationSection));
177177
}
178-
else
178+
else if (!_topElement)
179179
{
180180
yield return new KeyValuePair<string, string>("name", GetConfigKey(_configurationSection));
181181
}

test/NLog.Extensions.Logging.Tests/NLogLoggingConfigurationTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ private static NLogLoggingConfiguration CreateNLogLoggingConfigurationWithNLogSe
273273
private static Dictionary<string, string> CreateMemoryConfigConsoleTargetAndRule(string sectionName = DefaultSectionName)
274274
{
275275
var memoryConfig = new Dictionary<string, string>();
276+
memoryConfig[$"{sectionName}:throwConfigExceptions"] = "true";
276277
memoryConfig[$"{sectionName}:Rules:0:logger"] = "*";
277278
memoryConfig[$"{sectionName}:Rules:0:minLevel"] = "Trace";
278279
memoryConfig[$"{sectionName}:Rules:0:writeTo"] = "File,Console";

0 commit comments

Comments
 (0)