Ads by Lake Quincy Media

Wiki Navigation

 
Gibraltar - Learn about the best analysis tool for NLog

AsyncWrapper target

NLog documentation is a Wiki, which allows registered users to edit its content.
If you want to contribute, please create a user account and contact Jarek to get edit access.

Provides asynchronous, buffered execution of target writes. 

Supported in

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>
Read more about using the Configuration File.

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 <targets/> element in the configuration file. <targets async="true"> ... your targets go here ... </targets>

Ads by Lake Quincy Media