- Notifications
You must be signed in to change notification settings - Fork1.4k
FilteringWrapper target
Rolf Kristensen edited this pageNov 23, 2021 ·18 revisions
Filters log entries based on a condition.
Platforms Supported:All
Filtering using condition:
<targets> <targetxsi:type="FilteringWrapper"name="String"condition="Condition"> <targetxsi:type="wrappedTargetType" ...target properties... /> </target></targets>
Filtering using filter (Introduced with NLog 4.6.4):
<targets> <targetxsi:type="FilteringWrapper"name="default"> <targetxsi:type="wrappedTargetType" ...target properties... /> <filterxsi:type="whenRepeated"layout="${message}"timeoutSeconds="30"action="Ignore" /> </target></targets>
- name - Name of the target.
- condition -Condition Expression. Log events who meet this condition will be forwarded to the wrapped target. Condition Required, unless having specified afilter.
- filter - Filter expression. For complex filtering logic likeWhenRepeated-Filter.
Introduced with NLog 4.6.4
Filter repeated LogEvents, so it will only send mail every 5 minutes (Introduced with NLog 4.6.4):
<nlog> <targets> <targetxsi:type="FilteringWrapper"name="filter-mail"> <targetxsi:type="Mail"name="instant-mail"> <subject>${exception:format=Type}</subject> </target> <filtertype="whenRepeated"layout="${exception:format=Type}"timeoutSeconds="300"action="Ignore" /> </target> </targets> <rules> <loggername='*'minlevel='Debug'writeTo='filter-mail'/> </rules></nlog>
-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