NLog 4.2 is here!

24 Oct 2015

NLog 4.2 has been released. This release contains some small features and (important) bug fixes.

We take semver serious, so all changes are backwards-compatible.

Features

  • Performance Counter Target: it’s now possible to configure the step size for the counter target. Before the step size was always one.
  • Mail Target: pickupDirectoryLocation and deliveryMethod are configurable from the NLog config.
  • Cached Layout Renderer: a clearCache option has been added for more control over clearing the cache. See wiki.
  • File target: auto add .zip to compressed archive when archiveName isn’t specified.

Bug fixes

Inner layout can now contain colons

An inner layout can now contain colons, but it needs an escape.

It is required to escape : and } in an inner layout because:

  • : because it’s a value separator. ${when:when=1 == 1:Inner=Test\: Hello}
  • } because it can be the end of another layout renderer when double nested. ${rot13:inner=${rot13:inner=${when:when=1 == 1:Inner=Test \} Hello}}}

Other bugfixes

  • Colored Console Target: highlight whole words was broken.
  • Mail Target: when useSystemNetMailSettings was false, some settings were still used from the <mailSettings> of the .Net config.
  • Removed unnecessary System.Drawing references for Xamarin.
  • File Target: sometimes an exception was thrown when archiving was enabled.
  • File Target: file archiving DateAndSequence & FileArchivePeriod.Day won’t always work.
  • GetTargetsByLevelForLogger could throw a “Collection was modified” exception.

No bug nor feature

Improved document and error messages regarding the ‘type’ argument of Getcurrentclasslogger and GetLogger. Please keep in mind:

  • It should inherit from Logger.
  • Instead of creating an instance of Logger, it will create an instance of loggerType.
  • type argument necessary when using custom Loggers. Most of the time it isn’t required to pass a type to those methods.

We improved other docs and internal logging in the code. Our code coverage has also been increased.

Thanks

The NLog team has expanded greatly! We’d like to thank all the collaborators who have made this release possible:

Happy coding!

Julian (@304NotModified)