-
Notifications
You must be signed in to change notification settings - Fork 0
AsyncWrapper target
Provides asynchronous, buffered execution of target writes.
Supported in .NET, Silverligt, Compact Framework and Mono. ##Configuration Syntax
<targets>
<target xsi:type="AsyncWrapper"
name="String"
queueLimit="Integer"
timeToSleepBetweenBatches="Integer"
batchSize="Integer"
overflowAction="Enum">
<target xsi:type="wrappedTargetType" ...target properties... />
</target>
</targets>
##Parameters ###General Options name - Name of the target. ###Buffering Options queueLimit - Limit on the number of requests in the lazy writer thread request queue. Integer Default: 10000
timeToSleepBetweenBatches - Time in milliseconds to sleep between batches. Integer Default: 50
batchSize - Number of log events that should be processed in a batch by the lazy writer thread. Integer Default: 100
overflowAction - Action to be taken when the lazy writer thread request queue count exceeds the set limit. Default: Discard
Possible values:
-
Block - Block until there's more room in the queue.
This parameter is not supported in:
- NLog v1.0 for .NET Compact Framework 1.0
- NLog v1.0 for .NET Compact Framework 2.0
- NLog v2.0 for .NET Compact Framework 2.0
- NLog v2.0 for .NET Compact Framework 3.5
-
Discard - Discard the overflowing item.
-
Grow - Grow the queue.
##Remarks Asynchronous target wrapper allows the logger code to execute more quickly, by queueing messages and processing them in a separate thread. You should wrap targets that spend a non-trivial amount of time in their Write() method with asynchronous target to speed up logging. Because asynchronous logging is quite a common scenario, NLog supports a shorthand notation for wrapping all targets with AsyncWrapper. Just add async="true" to the element in the configuration file.
<targets async="true">
... your targets go here ...
</targets>