Skip to content

Latest commit

 

History

History

NLog.Web.AspNetCore

NLog.Web.AspNetCore integrates NLog as a logging provider for Microsoft.Extensions.Logging by calling UseNLog() on the application HostBuilder.

Application code can continue using ILogger<T>, while NLog provides powerful logging capabilities including:

Supported platforms:

  • ASP.NET Core 6, 7, 8, 9 and 10
  • ASP.NET Core 2, .NET Standard 2.0 and .NET 4.6.2+

Register NLog as logging provider:

builder.Logging.ClearProviders();
builder.Host.UseNLog();

If logging is needed before the host building, then one can use fluent setup:

var logger = NLog.LogManager.Setup().LoadConfigurationFromAppSettings().GetCurrentClassLogger();

Useful Links: