Skip to content

AspNet User Claim Layout Renderer

Rolf Kristensen edited this page Oct 30, 2024 · 4 revisions

ASP.NET User Claims authorization values.

Platforms Supported: All

Introduced with NLog.Web.AspNetCore v4.10.0, and with NLog.Web v5.1.0 for NET46

Configuration Syntax

${aspnet-user-claim:ClaimTypes.Name}

Parameters

ClaimType - default parameter. Key to lookup using ClaimsIdentity.FindFirst(string) with fallback to ClaimsPrincipal.FindFirst(string). When value is prefixed with ClaimTypes. (Remember dot) then it will lookup in well-known claim types from ClaimTypes-constants. For example ClaimsTypes.Name

NLog.Web.AspNetCore v5.3.3 supports outputting all values, when not having specified any ClaimType.

Formatting options

NLog.Web.AspNetCore v5.3.3 supports the following formatting options, when outputting all value by not specifying any ClaimType:

  • outputFormat - Renders as flat string or as JSON. Default: Flat.
    • Flat - Key-value-pair as standard string
    • JsonArray - Key-value-pair in JSON-array
    • JsonDictionary - Key-value-pair as JSON-dictionary
  • itemSeparator - Separator between items. Default: ,. Only applies when OutputFormat is Flat.
  • valueSeparator - Separator between value and key. Default: =. Only applies when OutputFormat is Flat.
  • ValuesOnly - Only render the values of the key/value pairs. Default: false.
  • LowerCaseKeys - Convert Keys to lowercase. Default: false.

Remarks

See also ClaimTypes-constants.

Clone this wiki locally