Skip to content
Rolf Kristensen edited this page Oct 29, 2023 · 16 revisions

Represents a string with embedded placeholders that can render contextual information from the LogEvent.

Platforms Supported: All

Configuration Syntax

SimpleLayout is used by default when nothing specified, so one can just write:

<targets>
  <target layout="Hello ${message}" />
</targets>

But one can explictly specify the SimpleLayout-type like this:

<targets>
  <target>
    <layout xsi:type="SimpleLayout" text="Hello ${message}" />
  </target>
</targets>

Parameters

Layout Options

  • text - Layout text

Remarks

The layout is not meant to be built explicitly from code, instead assign a string, e.g. Layout l = "${longdate}|${level}|${logger}|${message}"

The layout can be literal text like "Hello", but can also contain Layout-Renderers like ${message}. See also: List of Layout-Renderers

Many NLog Targets has their Layout-option configured to this default-value: ${longdate}|${level:uppercase=true}|${logger}|${message:withexception=true}

There also exists Layout-types for more structured output-formats like JSON, XML, CSV, etc. See also: List of Layouts

Clone this wiki locally