NLog cpu performance issue
According to this thread I would also guess that setting a higher number for timeToSleepBetweenBatches should reduce the high cpu time. Seems that the 2.0 beta of NLog should fix this behavor by only having one lazy writer thread running at a time.
In the meanwhile you don't have to change the source code to change timeToSleepBetweenBatches. You can set it in the configuration file:
<targets>
<target xsi:type="AsyncWrapper"
name="String"
queueLimit="Integer"
timeToSleepBetweenBatches="Integer"
batchSize="Integer"
overflowAction="Enum">
<target xsi:type="wrappedTargetType" ...target properties... />
</target>
</targets>
Buffering Options
timeToSleepBetweenBatches - Time in milliseconds to sleep between batches.Integer Default: 50
I took a brief look into the sources. My guess:
try to change ctor AsyncTargetWrapper(wrappedTarget, queueLimit, overflowAction) ...
this.TimeToSleepBetweenBatches = 50;
to something less frequent:
this.TimeToSleepBetweenBatches = 1000;
so the internal timer will not fire every 50ms !