- Notifications
You must be signed in to change notification settings - Fork1.4k
JsonArrayLayout
Rolf Kristensen edited this pageJun 30, 2024 ·9 revisions
A specialized layout that renders to JSON-Array. See alsoJsonLayout
Platforms Supported:All
Introduced with NLog 5.0
<targetname="jsonFile"xsi:type="File"fileName="log-file.json" > <layoutxsi:type="JsonArrayLayout"> <itemtype='SimpleLayout'text='${date:format=o}' /> <itemtype='SimpleLayout'text='${level}' /> <itemtype='SimpleLayout'text='${message}' /> </layout></target>
Example output:
["2010-01-01T12:34:56Z","Info","hello world" ]
- Items
- type - Required. The type of
Layout(Ex.SimpleLayout,JsonLayout, etc.)
- type - Required. The type of
- suppressSpaces - Enable to suppress extra spaces in the output JSON. Default:
false. - renderEmptyObject - When no array-items, then it should still render empty array-value
[]. Default:true.
-Troubleshooting Guide - See available NLog Targets and Layouts:https://nlog-project.org/config
- All targets, layouts and layout renderers
Popular: - Using NLog with NLog.config
- Using NLog with appsettings.json