With each logging call, context map data is copied from the ThreadContext map into the LogEvent.
The LogEvent interface exposes this data via the getContextMap() : Map<String, String> method, and this is implementated by storing the data in a Map<String, String>. The JDK Map is not an easy data structure to make garbage-free. It would also be nice to have the ability in LogEvent to carry data of any type.
One idea is to introduce a small interface that is general enough to be map-like but can be implemented in a garbage-free manner.
LogEvent implementations would have an instance of this interface instead of the current java.util.Map<String, String> contextMap attribute.
The interface could look something like this:
The LogEvent interface would have an additional method getContextData() : ContextData<K, V> that gives downstream components direct access to the new data structure.
Existing downstream components would still be able to call logEvent.getContextMap() to get a Map<String, String> view of the context map data and this would work as expected.