This package is an extension to NLog.
This package contains targets and layout-renderes specific to ASP.Net and IIS.
There is a special package for ASP.NET 5 / MVC 6. This is needed because HttpContext.Current
isn't available in ASP.NET 5 and we can't detect if ASP.NET 4 or 5 is used.
The following parts are supported in ASP.NET 5:
- aspnet-item
- aspnet-request (except ServerVariable)
- aspnet-session
- aspnet-user-authtype
- aspnet-user-identity
- iis-site-name
Please note:
In your nlog.config:
<extensions>
<!--enable NLog.Web for ASP.NET5-->
<add assembly="NLog.Web.ASPNET5"/>
</extensions>
In your startup.cs
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
//add NLog to aspnet5
loggerFactory.AddNLog();
//add NLog.Web (only needed if NLog.Web.ASPNET5 is needed)
app.AddNLogWeb();
//configure nlog.config in your project root
env.ConfigureNLog("nlog.config");
in project.json:
"dependencies": {
"NLog.Extensions.Logging": "1.0.0-rc1-final-2016-03-11",
"NLog.Web.ASPNET5": "4.2.2"
},
This package contains one target, one target-wrapper, multiple layout renderers and one httpmodule.
- AspNetTrace
- AspNetBufferingWrapper
See Target documentation at the NLog wiki
- ${aspnet-application} - ASP.NET Application variable.
- ${aspnet-item} - ASP.NET
HttpContext
item variable. - ${aspnet-request} - ASP.NET Request variable.
- ${aspnet-session} - ASP.NET Session variable.
- ${aspnet-sessionid} - ASP.NET Session ID.
- ${aspnet-user-authtype} - ASP.NET User variable.
- ${aspnet-user-identity} - 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