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 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 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.
- 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 CoreLogManager.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 aspnet-core-example:
- Install dotnet: http://dot.net
- From source:
dotnet run
- or, after publish:
dotnet aspnet-core-example.dll