AspNetRequest layout renderer
ASP.NET Request variable.
Platforms Supported: All
This layout renderer is broken down to separate layout renders who are more ASP.NET Core compatible / future proof:
- ${aspnet-HttpContext-Item} - ASP.NET HttpContext Item Value.
- ${aspnet-Request-Cookie} - ASP.NET Request cookie content.
- ${aspnet-Request-Host} - ASP.NET Request host.
- ${aspnet-Request-Ip} - ASP.NET Request Client IP address
- ${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-Request-Headers} - ASP.NET Request Headers.
- ${aspnet-Request-ServerVariable} - ASP.NET Server Variable.
-
${aspnet-User-Identity} - ASP.NET User Identity (Similar to
AUTH_USER
/REMOTE_USER
/LOGON_USER
)
And there are many more NLog LayoutRenderers to choose from
${aspnet-request:cookie=String:serverVariable=String:queryString=String
:item=String:form=String:header=String}
- cookie - Cookie to be rendered.
- header - Request header to be rendered. Introduced in NLog.Web 4.2
-
serverVariable - ServerVariables item to be rendered. See for possible options: msdn.
Not supported on ASP.NET Core until NLog.Web.AspNetCore v5.1
- queryString - QueryString variable to be rendered.
- item - HttpConterxt Item name to be rendered.
- form - Form variable to be rendered. Note: The Form property is populated when the HTTP request Content-Type value is either "application/x-www-form-urlencoded" or "multipart/form-data". (see msdn)
Use this layout renderer to insert the value of the specified parameter of the ASP.NET Request object. This renderer requires the NLog.Web package.
Full URL without domain, eg default.aspx?id=512
${aspnet-request:serverVariable=HTTP_URL}${aspnet-request:queryString}
URL doing the request. Including schema (e.g https://
) and querystring
${aspnet-request:header=Referer}
Content-Type like application/json; charset=UTF-8
${aspnet-request:header=Content-Type}
Method like PUT, POST, GET etc
${aspnet-request:serverVariable=REQUEST_METHOD}
user agent, like Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36
${aspnet-request:serverVariable=HTTP_USER_AGENT}
- Troubleshooting Guide - See available NLog Targets and Layouts: https://nlog-project.org/config
- Getting started
- How to use structured logging
- Troubleshooting
- FAQ
-
All targets, layouts and layout renderers
Popular: - Using NLog with NLog.config
- Using NLog with appsettings.json