Skip to content

Replace NewLines Layout Renderer

Rolf Kristensen edited this page Jun 9, 2022 · 8 revisions

Replaces a new lines in the output of another layout with a string.

Platforms Supported: All

Introduced in NLog 4.1

For general purpose search and replace there is also ${replace}

Configuration Syntax

${replace-newlines:inner=Layout:replacement=String}

Parameters

  • replacement - Text to replace newlines with. Default is " " (space)

Examples

logger.Info("foo {0}",  "bar" + System.Environment.NewLine + "123");

To space

${replace-newlines:${message}}

Will result in "foo bar 123"

To other char

${replace-newlines:replacement=|:${message}}

Will result in "foo bar|123"

Clone this wiki locally