I have problem with this method in NLog library: NLog.Targets.Wrappers.AsyncTargetWrapper.ProcessPendingEvents(object state)
It consume too much cpu time. I have long running windows service using Nlog and after two days my service consume over 80% cpu time (one core is almost on 80%, second 30%). It is not 100% cpu time but it is changing and after cca 2 hours its back to normal. So I have run profiler and this metod maybe cause it: NLog.Targets.Wrappers.AsyncTargetWrapper.ProcessPendingEvents(object state)
I have 10 file targets all are setted as async. It is a fact that I have lot of logging in my app but only on level Trace, if I switched to Info level it not helped.
Can you help me, should I decrease logging in my app?
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With