Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Environment User Layout Renderer

Rolf Kristensen edited this page Jun 22, 2025 · 7 revisions

Thread User identity information (username).

Platforms Supported: All

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

Morty Proxy This is a proxified and sanitized view of the page, visit original site.