Skip to content

Environment User Layout Renderer

Rolf Kristensen edited this page Mar 13, 2023 · 6 revisions

Thread User identity information (username).

Platforms Supported: Limited (Not supported on NetStandard1.3+1.5)

Introduced with NLog ver. 4.6.4

Configuration Syntax

${environment-user:userName=Boolean:domain=Boolean}

Parameters

Rendering Options

  • 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

Notes

  • 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.

Clone this wiki locally