-
Notifications
You must be signed in to change notification settings - Fork 1.4k
SimpleLayout
Represents a string with embedded placeholders that can render contextual information from the LogEvent.
Platforms Supported: All
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>
- text - Layout text
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
- Troubleshooting Guide - See available NLog Targets and Layouts: https://nlog-project.org/config
- Getting started
- How to use structured logging
- Troubleshooting
- FAQ
- Articles about NLog
-
All targets, layouts and layout renderers
Popular: - Using NLog with NLog.config
- Using NLog with appsettings.json