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
Rolf Kristensen edited this page Mar 5, 2025 · 18 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}

NLog Layout-format recognizes the colon-character : as option-delimiter, but only when used inside ${ and }. To avoid unexpected results, then one can escape using back-slash like this: \:. Ex. ${date:format=HH\:mm\:ss}

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

Clone this wiki locally

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