Search code examples
.net-6.0nlog

NLogConfigurationException: Error loading extensions: NLog.Extended


I am following this post to configure NLog to write to a text file in my .Net 6.0 Web api project

https://medium.com/projectwt/nlog-with-ilogger-in-net-6-0-web-api-fb7072d8ac6c

But when I run the project I get these errors

NLogConfigurationException: Error loading extensions: NLog.Extended

FileNotFoundException: Could not load file or assembly 'NLog.Extended, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.

on this line

var app = builder.Build();

I tried to search for NLog.Extended nuget package but found out that it is deprecated and the suggested substitute package is NLog.MSMQ so I installed it but that too did not help.

So I added the deprecated package NLog.Extended and then the error went away.

Now everything is working fine but the package NLog.Extended is definitely not made for .NET 6 and so I see this warning

enter image description here

What should I do?


Solution

  • The nuget-package-package page for NLog.Extended says:

    NLog.Extended nuget-package will no longer be released, and should be removed

    There nothing in the guide that you posted that mentions adding NLog.Extended as project-dependency. Also NLog.Extended only works with .NET Framework (and not with target-platforms like NET6/NET8)

    I suggest that you remove NLog.Extended-nuget-package from your application (both as nuget-package-dependency and also from NLog.config-file). If you depend on the VERY exotic MSMQ-target, then you can consider adding the dedicated NLog.MSMQ-nuget-package.