Nlog: Question on sync buffered flush

Created on 19 Nov 2018  路  2Comments  路  Source: NLog/NLog

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>
question

Most helpful comment

Thanks, it seems to work

All 2 comments

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:

  • timeToSleepBetweenBatches - Time to sleep between each batch-series.
  • fullBatchSizeWriteLimit - How many full batches to write in a single batch-series
  • batchSize - How many logevents to include in a full batch.

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

smeegoan picture smeegoan  路  3Comments

imanushin picture imanushin  路  3Comments

haythamabutair picture haythamabutair  路  3Comments

JustArchi picture JustArchi  路  3Comments

Jerefeny picture Jerefeny  路  3Comments