we are in the process of upgrading some projects to .NET 3.1
I get the following error after changing to 3.1:
'IWebHostEnvironment' does not contain a definition for 'ConfigureNLog' and the best extension method overload 'AspNetExtensions.ConfigureNLog(ILoggingBuilder, string)' requires a receiver of type 'ILoggingBuilder'
This is the code:
public static async Task Main(string[] args)
{
var builder = new WebHostBuilder();
var config = configurationBuilder.Build();
// it is possible to override the config file with command line arguments
var webHostBuilder = WebHost.CreateDefaultBuilder(args)
.UseConfiguration(config)
.ConfigureLogging((context, loggingBuilder) =>
{
if (File.Exists(".\\NLog.config"))
{
context.HostingEnvironment.ConfigureNLog(".\\NLog.config");
}
loggingBuilder.SetMinimumLevel(LogLevel.Trace);
})
.UseNLog()
.UseStartup<Startup>();
var webHost = webHostBuilder.Build();
await webHost.RunAsync().ConfigureAwait(false);
}
The line that breaks the code is:
context.HostingEnvironment.ConfigureNLog(".\\NLog.config");
we've updated our NLog to the latest version (4.14.0) I tried to install NLog.Extensions.Logging package (version 1.7.1)
I looked in NLog GitHub for some guides but could not find anything
Any help would be appreciated