Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Layout Renderers

Julian Verdurmen edited this page · 39 revisions
Clone this wiki locally

Layout renderers are template macros that are used in Layouts.

NLog supports creating custom layout renderers. For more information, see: Extending NLog

Layout Renderers

NLog package Version

NLog.Extended package Version

NLog.Web package Version

Wrapper Layout Renderers

NLog package Version

  • ${cached} - Applies caching to another layout output.
  • ${filesystem-normalize} - Filters characters not allowed in the file names by replacing them with safe character.
  • ${json-encode} - Escapes output of another layout using JSON rules.
  • ${lowercase} - Converts the result of another layout output to lower case.
  • ${onexception} - Only outputs the inner layout when exception has been defined for log message.
  • ${pad} - Applies padding to another layout output.
  • ${replace} - Replaces a string in the output of another layout with another string.
  • ${replace-newlines} - Replaces newline characters with another string.
  • ${rot13} - Decodes text "encrypted" with ROT-13.
  • ${trim-whitespace} - Trims the whitespace from the result of another layout renderer.
  • ${uppercase} - Converts the result of another layout output to upper case.
  • ${url-encode} - Encodes the result of another layout output for use with URLs.
  • ${when} - Only outputs the inner layout when the specified condition has been met.
  • ${whenEmpty} - Outputs alternative layout when the inner layout produces empty result.
  • ${xml-encode} - Converts the result of another layout output to be XML-compliant.

External packages

External packages, not maintained by the NLog team.

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 pass your own values in code by adding custom Properties to the event. You then retrieve the value using the ${event-context} renderer. See the documentation for the ${event-context} for an example.

Something went wrong with that request. Please try again.