AspNetRequest Url Layout Renderer
Rolf Kristensen edited this page Jun 10, 2023
·
10 revisions
ASP.NET Request URL
Platforms Supported: All
Introduced in NLog.Web 4.3
${aspnet-request-url:IncludeHost=boolean:IncludePort=boolean:IncludeQueryString=boolean:IncludeScheme=boolean}
-
Properties - Controls what parts of the Url to output. Default =
Scheme, Host, Path
Introduced with NLog v5.1.1
- Property Enum Values:
- Scheme
- Host
- Port
- Path
- Query
- Property Enum Values:
-
IncludeHost - Include the host name? (Assigns Properties |=
Host
). Default istrue
. -
IncludePort - Include the port number? (Assigns Properties |=
Port
). Default isfalse
. -
IncludeQueryString - include the querystring. (Assigns Properties |=
Query
). Default isfalse
. -
IncludeScheme - Includes the sheme? (Ex.
http://
orhttps://
) (Assigns Properties |=Scheme
). Default istrue
.Introduced in NLog.Web.AspNetCore v4.4.1 and NLog.Web v4.5.1.
-
IncludePath - Include the path? (Assigns Properties |=
Path
). Default istrue
.Introduced in NLog.Web.AspNetCore v5.0 and NLog.Web v5.0.
-
UseRawTarget - Extract the path from IHttpRequestFeature.RawTarget? Default is
false
.Introduced in NLog.Web.AspNetCore v4.9.2 (Not supported for NLog.Web)
${aspnet-request-url:IncludeQueryString=true} - produces http://www.exmaple.com/?t=1
${aspnet-request-url:IncludeQueryString=false} - produces http://www.exmaple.com/
${aspnet-request-url:IncludePort=true} - produces http://www.exmaple.com:80/
${aspnet-request-url:IncludePort=false} - produces http://www.exmaple.com/
${aspnet-request-url:IncludePort=true:IncludeQueryString=true} - produces http://www.exmaple.com:80/?t=1
${aspnet-request-url:IncludeScheme=false} - produces www.exmaple.com
- 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