I'm trying to use NLog (version 4.5.10) for displaying logs in WPF-application in GridView. For this I created custom target (LogsGridView) that do batch insert (with help of AsyncWrapper) of new rows to GridView (in main thread).
The problem that sometimes GUI freezes (too many logs per second). So now I want to use batch insert in sync mode with discard overflow action.
How I can achieve this? Is it possible to use BufferingWrapper in sync mode with discard overflow action? May be I need another approach.
<target name="gui_logs_batch" xsi:type="AsyncWrapper" timeToSleepBetweenBatches="250">
<target name="logs_grid"
xsi:type="LogsGridView"
layout="${message}${onexception:inner= [${exception}]}${when:when='${logger}'=='order':inner: ${event-properties:Order}}"
/>
</target>
If you read the documentation for the the AsyncWrapper:
https://github.com/nlog/NLog/wiki/AsyncWrapper-target
Then you will find these settings that will throttle:
Maybe this will give you the wanted throttle:
<target name="gui_logs_batch" xsi:type="AsyncWrapper" timeToSleepBetweenBatches="50" batchSize="50" fullBatchSizeWriteLimit="1">
<target name="logs_grid"
xsi:type="LogsGridView"
layout="${message}${onexception:inner= [${exception}]}${when:when='${logger}'=='order':inner: ${event-properties:Order}}"
/>
</target>
Thanks, it seems to work
Most helpful comment
Thanks, it seems to work