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 pageDec 27, 2023 ·3 revisions

Concatenate multiple layouts, so they become a single layout.

Platforms Supported:All

Introduced in NLog 4.3.6

<targetname='file'type='File'fileName='log.txt'>  <layouttype='CompoundLayout'>    <layouttype='SimpleLayout'text="text1" />    <layouttype='SimpleLayout'text=" -" />    <layouttype='SimpleLayout'text="text2" />  </layout></target>
text1 - text2

Advanced examples

From code

varcompoundLayout=newCompoundLayout{Layouts={newSimpleLayout("myAmazingText: "),newJsonLayout{Attributes={newJsonAttribute("time","${longdate}"),newJsonAttribute("level","${level:upperCase=true}"),}}}};
myAmazingText: { "time": "2016-10-30 13:30:55.0000", "level": "INFO" }

From XML

<nlog>  <targets>    <targetname='file'type='File'fileName='log.txt'>      <layouttype='CompoundLayout'>        <layouttype='SimpleLayout'text="myAmazingText:" />        <layouttype='JsonLayout'>          <attributename='time'layout='${longdate}' />          <attributename='level'layout='${level:upperCase=true}'/>        </layout>      </layout>    </target>  </targets>  <rules>  </rules></nlog>
myAmazingText: { "time": "2016-10-30 13:30:55.0000", "level": "INFO" }

-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