Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
/NLogPublic

FilteringWrapper target

Rolf Kristensen edited this pageNov 23, 2021 ·18 revisions

Filters log entries based on a condition.

Platforms Supported:All

Configuration Syntax

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>

Parameters

General Options

  • name - Name of the target.

Filtering Options

  • 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

Examples

Repeat filter

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

Configuration

Programmatic Configuration

Advanced

Extending NLog

Clone this wiki locally


[8]ページ先頭

©2009-2025 Movatter.jp