Description
The log4j2 API provides a ThreadContext - https://logging.apache.org/log4j/2.x/manual/thread-context.html - that allows items to be added to a stack or a map for logging, and then subsequently removed once they are no longer required.
This sounds like an ideal candidate for a AutoCloseable implementation so that items are removed automatically and no longer left around littering the stack/map.