Skip to content

DotNetLog/NLog.Extensions.Logging

 
 

Repository files navigation

NLog.Extensions.Logging

Build status Windows

NuGet Pre Release

NLog provider for Microsoft.Extensions.Logging; .NET Core. ASP.NET Core users should install NLog.Web.AspNetCore.

Routes .NET Core log messages to NLog.

Note: Microsoft haven't ported all their classes to .NET standard, so not every target/layout renderer is available. Please check platform support

ASP.NET Core

ASP.NET Core users should install NLog.Web.AspNetCore! This was needed to support also the non-ASP.NET users.

NLog.Web.AspNetCore has a dependency on this library, so there is no need to directly install it anymore.

Upgrading from alpha version?

Upgrading from the alphas? Some methods are moved to the NLog.Web.AspNetCore package.

Since the beta there is a ConfigureNLog on ILoggerFactory and on IHostingEnvironment. The difference is how the base path (for relative paths) are determined. IHostingEnvironment uses IHostingEnvironment.ContentRootPath and ILoggerFactory uses System.AppContext.BaseDirectory. ASP.NET Core users should use IHostingEnvironment.ConfigureNLog. NON-ASP.NET Core users (e.g. console applications), use ILoggerFactory.ConfigureNLog.

Due to the move of IHostingEnvironment.ConfigureNLog to NLog.Web.AspNetCore, the namespace of IHostingEnvironment.ConfigureNLog has been changed.

How to use

Known issues

  • Installing the NuGet packages NLog.config / NLog.schema won't add to your project. It's recommend to extract (unzip) the NLog.Schema package and place the NLog.XSD in the same folder as NLog.config.
  • auto load of NLog extensions won't work yet. Use <extensions> (see below)

.NET Core issues:

  • ${basedir} isn't working will in .NET Core
  • LogManager.GetCurrentClassLogger() will use the filename instead of the full class name (class name and namespace, like in NLog 4). This will be fixed in the final of NLog 5 (after the release of NETSTANDARD 2.0)

How to run the example (aspnet-core-example)

How to run the aspnet-core-example:

  1. Install dotnet: http://dot.net
  2. From source: dotnet run
  3. or, after publish: dotnet aspnet-core-example.dll

Releases

No releases published

Packages

No packages published

Languages

  • C# 97.6%
  • Shell 1.2%
  • Batchfile 1.2%