diff --git a/src/NLog.Extensions.Logging/Config/ExtensionLoggingConfiguration.cs b/src/NLog.Extensions.Logging/Config/ExtensionLoggingConfiguration.cs index 43ca9996..8b5d684f 100644 --- a/src/NLog.Extensions.Logging/Config/ExtensionLoggingConfiguration.cs +++ b/src/NLog.Extensions.Logging/Config/ExtensionLoggingConfiguration.cs @@ -54,11 +54,12 @@ public IEnumerable Children var children = _configurationSection.GetChildren(); foreach (var child in children) { - if (child.GetChildren().Any()) + var firstChildValue = child?.GetChildren()?.FirstOrDefault(); + if (firstChildValue != null) { if (_nameOverride == "target" && string.Equals(child.Key, "target", StringComparison.OrdinalIgnoreCase) && child.GetChildren().Count() == 1) { - yield return new LoggingConfigurationElement(child.GetChildren().First(), false, "target"); + yield return new LoggingConfigurationElement(firstChildValue, false, "target"); } else {