-
Notifications
You must be signed in to change notification settings - Fork 1.4k
JsonArrayLayout
Rolf Kristensen edited this page Jun 30, 2024
·
9 revisions
A specialized layout that renders to JSON-Array. See also JsonLayout
Platforms Supported: All
Introduced with NLog 5.0
<target name="jsonFile" xsi:type="File" fileName="log-file.json" >
<layout xsi:type="JsonArrayLayout">
<item type='SimpleLayout' text='${date:format=o}' />
<item type='SimpleLayout' text='${level}' />
<item type='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
- Getting started
- How to use structured logging
- Troubleshooting
- FAQ
- Articles about NLog
-
All targets, layouts and layout renderers
Popular: - Using NLog with NLog.config
- Using NLog with appsettings.json