From 9c5cd4b55ccfebc7460eedd03db72ee7cc2d8587 Mon Sep 17 00:00:00 2001 From: Tom Austin Date: Thu, 14 Jan 2021 10:16:35 +0000 Subject: [PATCH] Added clear to pending logs once indexed --- ElasticLogging/LoggingService.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ElasticLogging/LoggingService.cs b/ElasticLogging/LoggingService.cs index 3ae313b..aedaf6b 100644 --- a/ElasticLogging/LoggingService.cs +++ b/ElasticLogging/LoggingService.cs @@ -71,13 +71,19 @@ public async ValueTask DisposeAsync() public void Flush() { if (_pendingLogs.Any()) + { _elasticClient.IndexMany(_pendingLogs); + _pendingLogs.Clear(); + } } public async Task FlushAsync() { if (_pendingLogs.Any()) + { await _elasticClient.IndexManyAsync(_pendingLogs); + _pendingLogs.Clear(); + } } public void Fatal(Exception ex)