Skip to content

Upgrading NLog 5 to 6

Breaking5.5.1 → 6.2.2Breaking26Deprecated7New31Changed115Fixed45Other29

BreakingUpgrade verdict

24 breaking changes.

  • A ScopeContext option has a new name, so code using the old name must be updated.
  • The NLogViewer alias for the Log4JXml target is gone, so configurations using it must switch to the real name.
  • The Chainsaw target has a new name, so configurations referencing the old name must be updated.
  • The default file target no longer handles concurrent writes, though it can still keep files open.
Top 5 of 31 that need code or config changes

Target frameworks requirement changed in 6.0.0-preview1: .NETFramework3.5, .NETFramework4.5, .NETFramework4.6, .NETStandard1.3, .NETStandard1.5, .NETStandard2.0 → .NETFramework3.5, .NETFramework4.5, .NETFramework4.6, .NETStandard2.0, .NETStandard2.1.

Drops netstandard.library, system.componentmodel.primitives, system.componentmodel.typeconverter, system.data.common, system.diagnostics.process, system.diagnostics.stacktrace, system.diagnostics.tracesource, system.io.filesystem.watcher, system.net.http, system.net.nameresolution, system.net.requests, system.reflection.typeextensions, system.runtime.loader, system.text.regularexpressions, system.threading.thread, system.xml.xmldocument.

Breaking24
Renames ScopeContext CaptureNestedContext to CloneNestedContext.
ScopeContextCaptureNestedContextCloneNestedContext
Log4JXmlTarget removes the NLogViewer alias because it conflicts with other nuget packages.
Log4JXmlTargetNLogViewer
Renames ChainsawTarget to Log4JXmlTarget to match Log4JXmlEventLayout.
ChainsawTargetLog4JXmlTargetLog4JXmlEventLayout
New FileTarget drops ConcurrentWrites support but still supports KeepFileOpen (true/false).
FileTargetConcurrentWritesKeepFileOpen
Removes dependency on System.Text.RegularExpressions and introduces new nuget-package NLog.RegEx.
System.Text.RegularExpressionsNLog.RegEx
Extracts NLog.WindowsRegistry into its own git repository.
NLog.WindowsRegistry
Extracts NLog.Targets.Trace into its own git repository.
NLog.Targets.Trace
Extracts NLog.Targets.ConcurrentFile into its own git repository.
NLog.Targets.ConcurrentFile
Extracts NLog.Targets.Database into its own git repository.
NLog.Targets.Database
Extracts NLog.Targets.Mail into its own git repository.
NLog.Targets.Mail
Extracts NLog.Targets.WebService into its own git repository.
NLog.Targets.WebService
Extracts features into separate nuget packages, including NLog.Targets.AtomicFile for FileTarget with ConcurrentWrites using atomic file-append.
NLog.Targets.AtomicFileFileTargetConcurrentWritesNLog.Targets.ConcurrentFile
FileTarget refactors file-archive-logic with ArchiveSuffixFormat.
FileTargetArchiveSuffixFormat
Extracts NLog.Targets.GZipFile for FileTarget with EnableArchiveFileCompression using GZipStream.
NLog.Targets.GZipFileFileTargetEnableArchiveFileCompressionGZipStream
Extracts NLog.Targets.Mail, whose MailTarget depends on System.Net.Mail.SmtpClient.
NLog.Targets.MailMailTargetSystem.Net.Mail.SmtpClient
Extracts NLog.Targets.Network, whose NetworkTarget depends on TCP and UDP sockets and adds Syslog and Graylog support.
NLog.Targets.NetworkNetworkTarget
Extracts NLog.Targets.Trace, whose TraceTarget and NLogTraceListener depend on System.Diagnostics.Trace.
NLog.Targets.TraceTraceTargetNLogTraceListenerSystem.Diagnostics.TraceListenerSystem.Diagnostics.Trace
Extracts NLog.Targets.WebService, whose WebServiceTarget depends on System.Net.Http.HttpClient.
NLog.Targets.WebServiceWebServiceTargetSystem.Net.Http.HttpClient
Extracts NLog.RegEx, which depends on System.Text.RegularExpressions.
NLog.RegExSystem.Text.RegularExpressions
Moves old FileTarget into the new nuget-package NLog.Targets.ConcurrentFile.
FileTargetNLog.Targets.ConcurrentFile
Moves MailTarget into the new nuget-package NLog.Targets.Mail.
MailTargetNLog.Targets.Mail
Moves NetworkTarget into the new nuget-package NLog.Targets.Network.
NetworkTargetNLog.Targets.Network
Moves TraceTarget and NLogTraceListener into the new nuget-package NLog.Targets.Trace.
TraceTargetNLogTraceListenerNLog.Targets.Trace
Moves WebServiceTarget into the new nuget-package NLog.Targets.WebService.
WebServiceTargetNLog.Targets.WebService
Deprecated7
Marks ConfigurationItemFactory.ParseMessageTemplates as obsolete.
ConfigurationItemFactoryParseMessageTemplates
Marks ConditionParser as obsolete so it can become internal.
ConditionParser
Marks SimpleLayout Renderers property as obsolete.
SimpleLayoutRenderers
Marks ConversionHelpers.TryParseEnum as obsolete.
ConversionHelpers.TryParseEnum
Obsoletes CleanNamesOfAnonymousDelegates and CleanNamesOfAsyncContinuation in CallSiteLayoutRenderer.
CallSiteLayoutRendererCleanNamesOfAnonymousDelegatesCleanNamesOfAsyncContinuation
Marks [RequiredParameter] as obsolete and replaces it with explicit option validation during initialization.
RequiredParameter
Marks LogEventInfo.SequenceID and ${sequenceid} as obsolete, recommending ${counter:sequence=global} instead.
LogEventInfo.SequenceID${sequenceid}${counter:sequence=global}