I am trying to configure NLog
in my Azure Function
solution, unfortunately I am getting an error as below.
'ILoggingBuilder' does not contain a definition for 'AddNLog' and no accessible extension method 'AddNLog' accepting a first argument of type 'ILoggingBuilder' could be found
Please be noted that I had already installed the NLog
Nuget package to my project. Here is the code I am using in my Startup.cs
file.
using Microsoft.Azure.Functions.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection;
using NLog;
[assembly: FunctionsStartup(typeof(Adapter.Startup))]
namespace Adapter {
public class Startup: FunctionsStartup {
public override void Configure(IFunctionsHostBuilder builder) {
builder.Services.AddHttpClient();
builder.Services.AddLogging(logBuilder = >{
logBuilder.AddNLog();
});
}
}
}
Have you ever faced this issue?
Finally I was able to solve this issue by installing the Nuget
package called NLog.Extensions.Logging
. Please be noted that it has a dependency of NLog
.
There was an open issue in GitHub, that helped me resolving this issue.