serilog-sinks-elasticsearch icon indicating copy to clipboard operation
serilog-sinks-elasticsearch copied to clipboard

Failed send batch of one log have exception.

Open nipua opened this issue 4 years ago • 3 comments

It`s normal behavior, when one some kind log method raised an exception, is not send a batch to elasticsearch with other logs?

Logger.Log("foo");
Logger.Error(String.Format("{0} {1} {2} {3}", method, result.StatusCode, input.TenderId)); // Wrong! Exception!
Logger.Log("bar");

nipua avatar Nov 06 '19 08:11 nipua

No it is not. All data is buffered and send as one batch operation. Check with the serilog selflog functionality is there is any issue. If you run this inside a small console app, make sure to call the Logger.CloseAndFlush to everything is indeed submitted before closing.

mivano avatar Nov 13 '19 07:11 mivano

Thanks. In self logs, I have errors one type: 2019-11-12T14:20:24.0582513Z Exception while emitting periodic batch from Serilog.Sinks.Elasticsearch.ElasticsearchSink: System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary. at System.ThrowHelper.ThrowKeyNotFoundException() at System.Collections.Generic.Dictionary2.get_Item(TKey key) at Serilog.Sinks.Elasticsearch.ElasticsearchSink.EmitBatch(IEnumerable1 events) at Serilog.Sinks.PeriodicBatching.PeriodicBatchingSink.<EmitBatchAsync>d__15.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Serilog.Sinks.PeriodicBatching.PeriodicBatchingSink.<OnTick>d__16.MoveNext()

nipua avatar Nov 13 '19 13:11 nipua

It is trying to parse the results of the batch operation. It might be that it cannot handle the return values due to a version mismatch. There has been some recent changes in this code, are you running with the latest package?

mivano avatar Nov 26 '19 21:11 mivano