Layout Renderers - NLog/NLog GitHub Wiki

Layout renderers are template macros that are used in Layouts, e.g. ${message}, ${level} etc

Layout Renderers

List of available layout renderers can be found here: https://nlog-project.org/config/?tab=layout-renderers

NLog can also be extended with new custom layout renderers. See also: Extending NLog

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}

Passing Custom Values to a Layout

Even though the layout renderers provide many pre-defined values, you may need to pass application specific values to your Layouts. You can provide own Context state, that can then be rendered by different Layouts. For example by using LogEvent Properties, that can be rendered using using the ${event-properties} renderer.