Skip to content
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" ]

Parameters

  • Items
    • type - Required. The type of Layout (Ex. SimpleLayout, JsonLayout, etc.)
  • 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.
Clone this wiki locally