A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/nlog/NLog/wiki/BufferingWrapper-target below:

BufferingWrapper target · NLog/NLog Wiki · GitHub

A target that buffers log events and sends them in batches to the wrapped target.

Platforms Supported: All

<targets>
  <target xsi:type="BufferingWrapper"
          name="String"
          bufferSize="Integer"
          flushTimeout="Integer"
          slidingTimeout="Boolean"
          overflowAction="Enum">
    <target xsi:type="wrappedTargetType" ...target properties... />
  </target>
</targets>
Buffering and custom targets

When messages are written into the BufferingWrapper, then LogEvents are queued for writing at a later stage. There can be custom NLog targets that requires writing to happen on the main thread for proper context capture (without being queued). When used together with BufferingWrapper then context information can be lost.

By default all standard NLog targets supports use of BufferingWrapper. Custom NLog targets that inherits from TargetWithContext should also by default work correctly with BufferingWrapper.

Buffer and asynchronously writing

If flushTimeout is larger than 0, then the messages are written asynchronously. If the buffer is filled before the flushTimeout fires and triggers the asynchronous flush, then the logging thread will be performing the flush, and be blocked by the operation.

Because the BufferingWrapper is not intended for performance optimization, but for throttling or even discarding LogEvents. Then it can be a good idea to make use of the async attribute or the AsyncWrapper.

Send batch when triggered by event

This will send the last 50 messages to the myTargetType, when an Error occurs:

  <target name="String" xsi:type="AutoFlushWrapper"
          condition="level >= LogLevel.Error"
          flushOnConditionOnly="true">
     <target xsi:type="BufferingWrapper" bufferSize="50" overflowAction="Discard">
         <target xsi:type="myTargetType" ...target properties... />
     </target>
  </target>

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4