These packages are extensions to NLog.
The packages contain targets and layout-renderes specific to ASP.NET (Core), MVC and IIS.
ASP.NET Core: (ASP.NET Core 2 - install 4.5.x)
- Getting started with ASP.NET Core 2
- Getting started with .NET Core 2 Console application
- Getting started with ASP.NET Core 1 (csproj - vs2017)
- Getting Started with ASP.NET Core 1 (project.json - vs2015)
- Multiple blogs to get started with ASP.NET Core and NLog
For updates and releases, check CHANGELOG.MD or Releases
Simply install the package. NLog will detect the extension automatically.
ℹ️ Missing the trace en debug logs in .NET Core 2? Set ILoggingBuilder.SetMinimumLevel()
There is a special package for ASP.NET Core / MVC Core. This is needed because HttpContext.Current
isn't available in ASP.NET Core and we can't detect if ASP.NET or ASP.NET Core is used. The package depends on NLog.Extensions.Logging
The following parts are supported in ASP.NET Core:
- ${aspnet-Item} - ASP.NET
HttpContext
item variable. - ${aspnet-Request} - ASP.NET Request variable. (except ServerVariable)
- ${aspnet-Session} - ASP.NET Session variable.
- ${aspnet-SessionId} - ASP.NET Session ID variable.
- ${aspnet-User-AuthType} - ASP.NET User auth.
- ${aspnet-User-Identity} - ASP.NET User variable.
- ${iis-site-name} - IIS site name.
Introduced in NLog.Web 4.3 & NLog.Web.AspNetCore 4.3
- ${aspnet-MVC-Action} - ASP.NET MVC action name
- ${aspnet-MVC-Controller} - ASP.NET MVC controller name
- ${aspnet-Request-Cookie} - ASP.NET Request cookie content.
- ${aspnet-Request-Host} - ASP.NET Request host.
- ${aspnet-Request-Method} - ASP.NET Request method (GET, POST etc).
- ${aspnet-Request-QueryString} - ASP.NET Request querystring.
- ${aspnet-Request-Referrer} - ASP.NET Request referrer.
- ${aspnet-Request-UserAgent} - ASP.NET Request useragent.
- ${aspnet-Request-Url} - ASP.NET Request URL.
Introduced in NLog.Web.AspNetCore 4.3.1
- ${aspnet-TraceIdentifier} - ASP.NET trace identifier
This package contains one target, one target-wrapper, multiple layout renderers and one httpmodule.
- AspNetTrace
- AspNetBufferingWrapper
See Target documentation at the NLog wiki
- ${aspnet-MVC-Action} - ASP.NET MVC action name
- ${aspnet-MVC-Controller} - ASP.NET MVC controller name
- ${aspnet-Application} - ASP.NET Application variable.
- ${aspnet-Item} - ASP.NET
HttpContext
item variable. - ${aspnet-Request} - ASP.NET Request variable.
- ${aspnet-Request-Cookie} - ASP.NET Request cookie content.
- ${aspnet-Request-Host} - ASP.NET Request host.
- ${aspnet-Request-Method} - ASP.NET Request method (GET, POST etc).
- ${aspnet-Request-QueryString} - ASP.NET Request querystring.
- ${aspnet-Request-Referrer} - ASP.NET Request referrer.
- ${aspnet-Request-UserAgent} - ASP.NET Request useragent.
- ${aspnet-Request-Url} - ASP.NET Request URL.
- ${aspnet-Session} - ASP.NET Session variable.
- ${aspnet-SessionId} - ASP.NET Session ID variable.
- ${aspnet-TraceIdentifier} - ASP.NET trace identifier
- ${aspnet-UserAuthType} - ASP.NET User auth.
- ${aspnet-UserIdentity} - ASP.NET User variable.
- ${iis-site-name} - IIS site name.
See Layout renderers documentation at the NLog wiki
For the targets and layout renderers, no additional configuration is needed.
The NLogHttpModule
needs a registration in the web.config:
<system.webServer>
<modules runAllManagedModulesForAllRequests="true">
<add name="NLog" type="NLog.Web.NLogHttpModule, NLog.Web" />
</modules>
</system.webServer>
BSD