Closed
Description
In file SerilogLogger, in the function LogEvent PrepareWrite<TState>(LogEventLevel level, EventId eventId, TState state, Exception? exception, Func<TState, Exception?, string> formatter)
, if the state is IEnumerable<KeyValuePair<string, object> already contains a property "EventId", the following exception is triggered :
Failed to write event through SerilogLogger: System.ArgumentException: An item with the same key has already been added. Key: EventId.
Solution :
Replace :
properties.Add("EventId", _eventIdPropertyCache.GetOrCreatePropertyValue(in eventId));
By :
properties["EventId"] = _eventIdPropertyCache.GetOrCreatePropertyValue(in eventId);