Skip to content

Upgrading NLog 3 to 4

Breaking3.2.1 → 4.7.15Breaking4Platform4Deprecated2New215Changed209Fixed223Other66

BreakingUpgrade verdict

4 breaking changes and 4 platform requirement changes.

  • Libraries built with newer LibLog will store nested and mapped context in NLog's newer MDLC and NDLC instead of the older MDC and NDC, so your NLog.config must be updated to match.
  • Exceptions are now handled the same way everywhere, which may change how errors surface in your app.
  • Custom targets that forget to call base.InitializeTarget() will now get an exception instead of silently misbehaving.
  • We reverted an unneeded breaking change in MailTarget.
Top 5 of 10 that need code or config changes

Requires Target frameworks .NETFramework3.5, .NETFramework4.0-Client, .NETFramework4.5, .NETStandard1.3, .NETStandard1.5, .NETStandard2.0, MonoAndroid4.4, Silverlight4.0, Silverlight5.0, WindowsPhone8.0, Xamarin.iOS1.0 from 4.7.9 (none stated before).

Breaking4
LibLog 5.0.3+ sub-components now use MDLC and NDLC instead of MDC and NDC when they detect NLog 4.6.
MDLCNDLCMDCNDCOpenNestedContextOpenMappedContext
Changes exception handling to be consistent, which is a behaviour change.
Throws an exception when base.InitializeTarget() is not called and inlines GetAllLayouts().
InitializeTarget()GetAllLayouts()
We reverted an unneeded breaking change in MailTarget.
MailTargetSMTP
Platform4
Adds support for Android 4.4.
Adds support for Windows Phone 8, Xamarin Android and Xamarin iOS (beta).
Adds beta support for Xamarin Android.
Adds beta support for Xamarin iOS.
Deprecated2
XmlLoggingConfiguration marks legacy constructors with ignoreErrors parameter as obsolete.
XmlLoggingConfiguration
Target.MergeEventProperties is now obsolete.
Target.MergeEventProperties