-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Environment User Layout Renderer
Thread User identity information (username).
Platforms Supported: Limited (Not supported on NetStandard1.3 1.5)
Introduced with NLog ver. 4.6.4
${environment-user:userName=Boolean:domain=Boolean}
- userName - Indicates whether username should be included. Boolean Default: True
- domain - Indicates whether domain name should be included. Boolean Default: False
- DefaultUser - Fallback value if unable to lookup username
- DefaultDomain - Fallback value if unable to lookup domain
-
On Windows the Environment.UserName property wraps a call to the Windows GetUserName function.
-
On Unix platforms the UserName property wraps a call to the getpwuid_r function.
-
If an ASP.NET application runs in a development environment, the UserName property returns the name of the current user. In a published ASP.NET application, this property returns the name of the application pool account (such as Default AppPool).
Alternative one can use ${windows-identity} that depends on WindowsIdentity.Getcurrent()
Another alternative is ${identity} that depends on Thread.CurrentPrincipal.
Yet another alternative is ${aspnet-user-identity} but it only works on ASP.NET Applications with identity enabled.
- Troubleshooting Guide - See available NLog Targets and Layouts: https://nlog-project.org/config
- Getting started
- How to use structured logging
- Troubleshooting
- FAQ
- Articles about NLog
-
All targets, layouts and layout renderers
Popular: - Using NLog with NLog.config
- Using NLog with appsettings.json