Skip to content

Level layout renderer

Rolf Kristensen edited this page Jun 6, 2023 · 14 revisions

The log level.

Platforms Supported: All

Configuration Syntax

${level:format=Ordinal}

Alternatively, add padding to align the message.

${pad:padding=5:inner=${level:uppercase=true}}

Alternatively, truncate to align the message:

${level:format=TriLetter:uppercase=true}

Parameters

  • uppercase - Output level in upper-case. Default: false

    Introduced with NLog v5.0 to simplify default Layout, instead of using the ambient uppercase-property

  • format - Output format of the level. Introduced in 4.4.6 Default: Name
    Possible values:

    • Name - Render the standard level name.

      Introduced in NLog 4.4.6

    • FullName - Render the full level name (Expands "Info" and "Warn")

      Introduced in NLog 4.7

    • FirstCharacter - Render the first character of the level.

      Introduced in NLog 4.4.6

    • Ordinal - Render the ordinal (aka number) for the level.

      Introduced in NLog 4.4.6

    • TriLetter - Renders LogLevel as 3 letter abbreviations (Trc, Dbg, Inf, Wrn, Err, Ftl)

      Introduced in NLog 5.0.5

    Name FullName TriLetter FirstCharacter Ordinal
    Trace Trace Trc T 0
    Debug Debug Dbg D 1
    Info Information Inf I 2
    Warn Warning Wrn W 3
    Error Error Err E 4
    Fatal Fatal Ftl F 5
    Off Off Off O 6

Examples

Basic

Configuration:

${level}

Code:

logger.Debug("Test Message")

Result:

Debug

Format

Configuration:

${level:format=FirstCharacter}

Code:

logger.Debug("Test Message")

Result:

D
Clone this wiki locally