Closed mahdiman closed 4 years ago
The problem turned out to be that inside the MicrosoftTeamsSink.cs:EmitBatchAsync:95 ... the query should check for null exceptions before accessing elements inside them as not all logEvents have exceptions.
I already fixed the issue, please give me contributor access to push changes.
This should be fixed now: https://github.com/SeppPenner/Serilog.Sinks.MicrosoftTeams/commit/d38a5a276e80384669f4a626bbeb3952b8a1f0ed.
By the way, you can fork the project, edit your fork and provide a pull request.
When setting BatchSizeLimit to a number > 1 the microsoft teams logger throws a null reference exception.
Self Log: 2020-07-13T08:38:01.3053211Z Exception while emitting periodic batch from Serilog.Sinks.MicrosoftTeams.MicrosoftTeamsSink: System.NullReferenceException: Object reference not set to an instance of an object. at Serilog.Sinks.MicrosoftTeams.MicrosoftTeamsSink.<>c__DisplayClass4_0.b__0(ExtendedLogEvent l)
at System.Linq.Enumerable.TryGetFirst[TSource](IEnumerable
1 source, Func
2 predicate, Boolean& found) at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable1 source, Func
2 predicate) at Serilog.Sinks.MicrosoftTeams.MicrosoftTeamsSink.EmitBatchAsync(IEnumerable`1 events) at Serilog.Sinks.PeriodicBatching.PeriodicBatchingSink.OnTick()