Upgrading NLog 4 to 5
Breaking4.7.15 → 5.5.1Breaking3Deprecated20New45Changed122Fixed57Other29
BreakingUpgrade verdict
3 breaking changes.
In plain terms
- Types no longer carry the Serializable attribute or support SerializationInfo-based serialization, which .NET 8 marks obsolete.
- Removes the irrelevant StructuredMessageTemplateAttribute from ILogger.
- The shorthand name DB for the database target has been removed, so configurations using it must switch to the full name.
- The RegisterType method on IFactory is deprecated and will be removed in NLog 6.
Must act Top 5 of 23 that need code or config changes
Target frameworks requirement changed in 5.0.0-preview.1: .NETFramework3.5, .NETFramework4.0-Client, .NETFramework4.5, .NETStandard1.3, .NETStandard1.5, .NETStandard2.0, MonoAndroid4.4, Silverlight4.0, Silverlight5.0, WindowsPhone8.0, Xamarin.iOS1.0 → .NETFramework3.5, .NETFramework4.5, .NETFramework4.6, .NETStandard1.3, .NETStandard1.5, .NETStandard2.0.
Adds system.net.http 4.3.4, system.text.regularexpressions 4.3.1.
Drops microsoft.extensions.platformabstractions.
What you must change
Breaking3
Removes the Serializable attribute and SerializationInfo support since they are obsolete in NET8.
SerializableSerializationInfoRemoves the irrelevant StructuredMessageTemplateAttribute from ILogger.
ILoggerStructuredMessageTemplateAttributeRemoves the DB alias from DatabaseTarget to avoid promoting acronyms.
DatabaseTargetDBDeprecations to plan for
Deprecated20
Marks IFactory RegisterType as obsolete, since it will be removed with NLog v6.
IFactoryRegisterTypeMarks JsonLayout EscapeForwardSlash as obsolete, since disabled with NLog v6.
JsonLayoutEscapeForwardSlashMarks ExceptionLayoutRenderer Formats-List as obsolete, since immutable with NLog v6.
ExceptionLayoutRendererFormatsMarks JsonLayout EscapeForwardSlash as obsolete.
JsonLayoutEscapeForwardSlashMarks NLogViewerTarget and IncludeNLogData as obsolete.
NLogViewerTargetIncludeNLogDataMarks XmlLoggingConfiguration AppConfig as obsolete.
XmlLoggingConfigurationAppConfigMarks XmlLoggingConfiguration InitializeSucceeded as obsolete.
XmlLoggingConfigurationInitializeSucceededMarks LogEventInfo SetStackTrace with UserStackFrameNumber as obsolete.
LogEventInfoSetStackTraceUserStackFrameNumberMarks SetupFromEnvironmentVariables and LogToTrace as obsolete.
SetupFromEnvironmentVariablesLogToTraceLogManager AddHiddenAssembly is marked obsolete; use AddCallSiteHiddenAssembly instead.
LogManager.AddHiddenAssemblyAddCallSiteHiddenAssemblyInternalLogger LogToTrace is marked obsolete to reduce dependencies.
InternalLogger.LogToTraceILoggerBase and ISuppress are marked obsolete; use ILogger instead.
ILoggerBaseISuppressILoggerLoggingRule ChildRules is marked obsolete.
LoggingRule.ChildRulesFileTarget NetworkWrites is marked obsolete and replaced by KeepFileOpen=false.
FileTarget.NetworkWritesKeepFileOpenEscapeDataNLogLegacy is marked obsolete.
EscapeDataNLogLegacyUpdates the obsolete warning for the ConfigurationReloaded event.
ConfigurationReloadedUpdates the obsolete warning for the ErrorException method and related methods.
ILoggerErrorExceptionMarks Target LayoutWithLock as obsolete since it is only a temporary workaround.
Target.LayoutWithLockMarks NLogRuntimeException constructor with string.Format as obsolete.
NLogRuntimeExceptionMarks the NLogConfigurationException constructor that takes a string.Format format and arguments as obsolete.
NLogConfigurationException