Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings
/NLogPublic
Rolf Kristensen edited this pageMar 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>  <targetlayout="Hello ${message}" /></targets>

But one can explictly specify theSimpleLayout-type like this:

<targets>  <target>    <layoutxsi: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 theirLayout-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 likeJSON,XML,CSV, etc. See also:List of Layouts

-Troubleshooting Guide - See available NLog Targets and Layouts:https://nlog-project.org/config

Configuration

Programmatic Configuration

Advanced

Extending NLog

Clone this wiki locally


[8]ページ先頭

©2009-2025 Movatter.jp