diff --git a/src/NLog/Config/LoggingConfiguration.cs b/src/NLog/Config/LoggingConfiguration.cs index c526d43f08..9d876ca3df 100644 --- a/src/NLog/Config/LoggingConfiguration.cs +++ b/src/NLog/Config/LoggingConfiguration.cs @@ -131,7 +131,7 @@ private Target RemoveTargetThreadSafe(string name) if (target != null) { - InternalLogger.Debug("Unregistered target {0}(Name={1})", target.GetType().Name, target.Name); + InternalLogger.Debug("Unregistered target {0}(Name={1})", target.GetType(), target.Name); } return target; @@ -160,11 +160,11 @@ private void AddTargetThreadSafe(Target target, string targetAlias = null) if (!string.IsNullOrEmpty(target.Name) && !string.Equals(target.Name, targetAlias, StringComparison.OrdinalIgnoreCase)) { - InternalLogger.Info("Registered target {0}(Name={1}) (Extra alias={2})", target.GetType().Name, target.Name, targetAlias); + InternalLogger.Info("Registered target {0}(Name={1}) (Extra alias={2})", target.GetType(), target.Name, targetAlias); } else { - InternalLogger.Info("Registered target {0}(Name={1})", target.GetType().Name, target.Name); + InternalLogger.Info("Registered target {0}(Name={1})", target.GetType(), target.Name); } } @@ -216,7 +216,7 @@ public void AddTarget([NotNull] Target target) { if (target is null) { throw new ArgumentNullException(nameof(target)); } - InternalLogger.Debug("Adding target {0}(Name={1})", target.GetType().Name, target.Name); + InternalLogger.Debug("Adding target {0}(Name={1})", target.GetType(), target.Name); if (string.IsNullOrEmpty(target.Name)) { throw new ArgumentException(nameof(target) + ".Name cannot be empty", nameof(target)); } @@ -235,7 +235,7 @@ public void AddTarget(string name, [NotNull] Target target) if (name is null) { throw new ArgumentNullException(nameof(name)); } if (target is null) { throw new ArgumentNullException(nameof(target)); } - InternalLogger.Debug("Adding target {0}(Name={1})", target.GetType().Name, string.IsNullOrEmpty(name) ? target.Name : name); + InternalLogger.Debug("Adding target {0}(Name={1})", target.GetType(), string.IsNullOrEmpty(name) ? target.Name : name); if (string.IsNullOrEmpty(name)) { throw new ArgumentException("Target name cannot be empty", nameof(name)); } diff --git a/src/NLog/Config/LoggingConfigurationParser.cs b/src/NLog/Config/LoggingConfigurationParser.cs index d583d8df84..f7cfa6611c 100644 --- a/src/NLog/Config/LoggingConfigurationParser.cs +++ b/src/NLog/Config/LoggingConfigurationParser.cs @@ -1348,7 +1348,7 @@ private Target WrapWithDefaultWrapper(Target target, ValidatedConfigurationEleme target.Name = target.Name + "_wrapped"; InternalLogger.Debug("Wrapping target '{0}' with '{1}' and renaming to '{2}", wrapperTargetInstance.Name, - wrapperTargetInstance.GetType().Name, target.Name); + wrapperTargetInstance.GetType(), target.Name); return wrapperTargetInstance; } diff --git a/src/NLog/Internal/Reflection/PropertyHelper.cs b/src/NLog/Internal/Reflection/PropertyHelper.cs index ba4df66c15..ba69960381 100644 --- a/src/NLog/Internal/Reflection/PropertyHelper.cs +++ b/src/NLog/Internal/Reflection/PropertyHelper.cs @@ -37,13 +37,11 @@ namespace NLog.Internal using System.Collections.Generic; using System.ComponentModel; using System.Globalization; - using System.Linq; using System.Reflection; using System.Text; using NLog.Common; using NLog.Conditions; using NLog.Config; - using NLog.Internal; using NLog.Layouts; using NLog.Targets; @@ -92,7 +90,6 @@ internal static class PropertyHelper internal static void SetPropertyFromString(object targetObject, string propertyName, string stringValue, ConfigurationItemFactory configurationItemFactory) { var objType = targetObject.GetType(); - InternalLogger.Debug("Setting '{0}.{1}' to '{2}'", objType, propertyName, stringValue); if (!TryGetPropertyInfo(objType, propertyName, out var propInfo)) { @@ -106,6 +103,8 @@ internal static void SetPropertyFromString(object targetObject, PropertyInfo pro { object propertyValue = null; + InternalLogger.Debug("Setting '{0}.{1}' to '{2}'", targetObject?.GetType(), propInfo.Name, stringValue); + try { var propertyType = Nullable.GetUnderlyingType(propInfo.PropertyType) ?? propInfo.PropertyType; diff --git a/src/NLog/Layouts/LayoutParser.cs b/src/NLog/Layouts/LayoutParser.cs index 04982bc677..efd9eda0b8 100644 --- a/src/NLog/Layouts/LayoutParser.cs +++ b/src/NLog/Layouts/LayoutParser.cs @@ -609,7 +609,7 @@ private static string SetDefaultPropertyValue(string value, LayoutRenderer layou value = EscapeUnicodeStringValue(value); } - PropertyHelper.SetPropertyFromString(layoutRenderer, propertyInfo.Name, value, configurationItemFactory); + PropertyHelper.SetPropertyFromString(layoutRenderer, propertyInfo, value, configurationItemFactory); return propertyInfo.Name; } else