datalust / nlog-targets-seq

An NLog target that writes events to Seq. Built for NLog 4.5+.
https://getseq.net
Apache License 2.0
21 stars 11 forks source link

Compatibility with NLog 5.0.0 #59

Closed jbennink closed 2 years ago

jbennink commented 2 years ago

After upgrading NLog to 5.0.0 and NLog.Extensions.Logging to 5.0.0 the Seq target does not work anymore. I get an exception on:

NLogConfigurationException: Failed to create Target of type: Seq NLog.Config.LoggingConfigurationParser.FactoryCreateInstance(string classType, INamedItemFactory<T, Type> factory)

I am using the default appsettings.json configuration as shown in the documentation for this package.

I did see in the breaking changes for NLog 5.0.0 that they changes some properties (such as bufferSize and flushTimeout from int to Layout in this commit part of changes to the BufferWrapper feature also used by this packages, see PR/Commit: https://github.com/NLog/NLog/pull/4858/files

The NLog 4.7.14 and NLog.Extensions.Logging 1.7.4 I was using in combination with NLog.Targets.Seq 2.1.0 does work. This prevents upgrading to NLog 5.0.0

snakefoot commented 2 years ago

Think you are seeing this breaking change: NLog Extensions assemblies will not load automatically

The solution is to update the NLog.config to include:

  <extensions>
    <add assembly="NLog.Targets.Seq"/>
  </extensions>

Or use the new feature in NLog v5 to include extension-assembly in type-alias:

  <target type="Seq, NLog.Targets.Seq" serverUrl="http://localhost:5341" apiKey="">
    <property name="ThreadId" value="${threadid}" as="number" />
  </target>
snakefoot commented 2 years ago

Created #60 that updates config-examples

jbennink commented 2 years ago

Yep that fixed the issue, thanks @snakefoot