GroupByWrapper target
Rolf Kristensen edited this page Nov 27, 2021
·
3 revisions
Allow one to to take an entire batch of logevents and group-by ex. request-identifier. Splitting the batch into individual emails / reports.
Platforms Supported: All (Introduced with NLog 5.0)
<targets>
<target xsi:type="GroupByWrapper"
name="String"
key="Layout">
<target xsi:type="wrappedTargetType" ...target properties... />
</target>
</targets>
- Key - Layout used for grouping the LogEvents into smaller batches.
Creates a buffer of the last 50 LogEvents, and flushes when receiving LogEvent with LogLevel.Error. Then groups the LogEvents by their individual request (Using ${activity} other correlationid). Then generates output only containing the LogEvents matching the failed request.
<target name="String" xsi:type="AutoFlushWrapper" condition="level >= LogLevel.Error" flushOnConditionOnly="true">
<target name="String" xsi:type="BufferingWrapper" bufferSize="50" overflowAction="Discard">
<target name="String" xsi:type="GroupByWrapper" key="${ActivityId}">
<target name="String" xsi:type="PostFilteringWrapper" defaultFilter="Ignore">
<when exists="level >= LogLevel.Error" filter="Log"/>
<target xsi:type="myTargetType" ...target properties... />
</target>
</target>
</target>
</target>
- Troubleshooting Guide - See available NLog Targets and Layouts: https://nlog-project.org/config
- Getting started
- How to use structured logging
- Troubleshooting
- FAQ
-
All targets, layouts and layout renderers
Popular: - Using NLog with NLog.config
- Using NLog with appsettings.json