Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Clone this wiki locally
A target that buffers log events and sends them in batches to the wrapped target.
Supported in .NET, Silverlight, Compact Framework and Mono.
<targets> <target xsi:type="BufferingWrapper" name="String" bufferSize="Integer" flushTimeout="Integer" slidingTimeout="Boolean" overflowAction="Enum"> <target xsi:type="wrappedTargetType" ...target properties... /> </target> </targets>
- name - Name of the target.
bufferSize - Number of log events to be buffered. When the limit is reached, then a synchronous flush is performed.
flushTimeout - Timeout (in milliseconds) after a write, until the entire buffer is asynchronously flushed. Use
-1to disable timed flushes.
slidingTimeout - Indicates whether to use sliding flushTimeout.
This value determines how the inactivity period is determined. If sliding timeout is enabled, the inactivity timer is reset after each write, if it is disabled - inactivity timer will count from the first event written to the buffer.
overflowAction - Action to be taken when the buffer exceeds the set
Flush. Introduced in NLog 4.5
- Flush - All the log events in the buffer will be written in the wrapped target.
- Discard - The oldest log event will be removed from the buffer. If this setting is used, the Flush action will need to be triggered manually using another wrapper like the AsyncWrapper or by using the
Buffer and asynchronously writing
flushTimeout is larger than
0, then the messages are written asynchronously. There is then no need to use this target in combination with the
async attribute or the AsyncWrapper.
When messages are written asynchronously, this is done in another thread. This means context information like thread-user-identity is different.
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.
Send batch when triggered by event
This will send the last 50 messages to the
wrappedTargetType, when an Error occurs:
<target name="String" xsi:type="AutoFlushWrapper" condition="level >= LogLevel.Error"> <target xsi:type="BufferingWrapper" bufferSize="50" overflowAction="Discard"> <target xsi:type="wrappedTargetType" ...target properties... /> </target>