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

PostFilteringWrapper target

Rolf Kristensen edited this pageJul 29, 2023 ·12 revisions

Filters buffered log entries based on a set of conditions that are evaluated on a group of events.

Platforms Supported:All

Configuration Syntax

<targets>  <targetxsi:type="AsyncWrapper"name="String">     <targetxsi:type="PostFilteringWrapper"name="String"defaultFilter="Condition">       <targetxsi:type="wrappedTargetType" ...target properties... />       <whenexists="Condition"filter="Condition"/><!-- repeated-->     </target>  </target></targets>

Parameters

General Options

  • name - Name of the target.

Filtering Options

  • defaultFilter - Default filter to be applied when no specific rule matches.Conditions

Filtering Rules

  • rules - The collection of filtering rules. The rules are processed top-down and the first rule that matches determines the filtering condition to be applied to log events. Collection
    Each collection item is represented by <when /> element with the following attributes:
    • exists - Condition to be tested.Conditions Required.
    • filter - Resulting filter to be applied when the condition matches.Conditions Required.

Remarks

Before NLog 4.6.4 then the filtering only worked when using PostFilteringWrapper with some type of buffering target or wrapper, such as AsyncTargetWrapper, BufferingWrapper or ASPNetBufferingWrapper. It is still a good idea add the wrapper when using therules filtering-logic (will inspect the entire batch when a single logevent matchesexists).

<targets>  <targetname="file"xsi:type="BufferingWrapper"bufferSize="100">    <targetxsi:type="PostFilteringWrapper"defaultFilter="level&gt;= LogLevel.Info">      <targetxsi:type="File"fileName="${basedir}/file.txt" />      <whenexists="level&gt;= LogLevel.Warn"filter="level&gt;= LogLevel.Debug"/>    </target>  </target></targets>

-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