Handling of Serilog.Events.LogEvent
in LokiBatchFormatter
is not thread-safe
#224
Labels
Serilog.Events.LogEvent
in LokiBatchFormatter
is not thread-safe
#224
Which version of Serilog.Sinks.Grafana.Loki are you using?
v8.2.0
Which version of .NET are you using?
net6.0
Describe the bug
Handling of
Serilog.Events.LogEvent
inLokiBatchFormatter
is not thread-safe.Method
AddLevelAsPropertySafely
modifiesSerilog.Events.LogEvent.Properties
(Dictionary<string, LogEventPropertyValue>
) and causes problems with simultaneous aceess to it from other threads (sinks).https://github.com/serilog-contrib/serilog-sinks-grafana-loki/blob/master/src/Serilog.Sinks.Grafana.Loki/LokiBatchFormatter.cs#L157-L158
serilog/serilog#1154 (comment)
Serilog's LogEvent is not thread-safe for readers concurrent with writers; concurrent reads are fine, but only in the absence of writes
To Reproduce
Configure at least one sink with async processing alongside Serilog.Sinks.Grafana.Loki, for example I use sinks:
Expected behavior
The original value of
Serilog.Events.LogEvent.Properties
should never be modified in sink.Log/SelfLog output or exception with stacktrace
Application or code sample, which could be used to reproduce a bug
No response
Additional context
No response
I have read the documentation
The text was updated successfully, but these errors were encountered: