serilog-sinks-elasticsearch
serilog-sinks-elasticsearch copied to clipboard
Failed send batch of one log have exception.
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");
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.
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()
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?