- Notifications
You must be signed in to change notification settings - Fork1
An NLog layout that writes JSON in Compact Log Event Format (CLEF) that is compatible with Seq.
License
paulem/nlog-layouts-clef
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
An NLog layout that writes JSON in Compact Log Event FormatCLEF that is compatible withSeq.
There are situations when it is not possible to send logs directly to Seq, for example, due to enterprise security policies. In this case, a Seq-compatible JSON log can be useful, which can be manually fed to Seq usingseqcliingest
command.
After installing NLog, install theNLog.Layouts.ClefJsonLayout
package from NuGet:
dotnet add package NLog.Layouts.ClefJsonLayout
Then, use theClefJsonLayout
layout within the file target in your NLog configuration:
<nlog> <extensions> <addassembly="NLog.Layouts.ClefJsonLayout"/> </extensions> <targets> <targetxsi:type="File"name="file"fileName="log.json"> <layoutxsi:type="ClefJsonLayout" /> </target> </targets> <rules> <loggername="*"minlevel="Info"writeTo="file" /> </rules></nlog>
Thelayout
declaration inNLog.config
can be expanded with additional properties:
<targetxsi:type="File"name="file"fileName="log.json"> <layoutxsi:type="ClefJsonLayout"> <attributename="logger"layout="${logger}"/> <attributename="thread"layout="${threadid}"/> </layout></target>
Any properties specified here will be attached to all outgoing events. The value can be any supportedlayout renderer.
The layout is the part of theNLog.Targets.Seq code that is responsible for generating JSON inCLEF.