Hi Andreas, On Mon, 29 Jan 2024 at 18:45, <andpr...@gmx.net.invalid> wrote: > Note, this happens even though effectively just two lines are really logged. > If DEBUG or TRACE were enabled in the loggers, then tens if not hundreds of > thousands of lines would be logged - so definitely, > there is a lot of logging going on. > > This has to do with the org.apache.logging.log4j.ThreadContext. > If I remove just the following one line from my code, then the performance is > back at normal. > > ThreadContext.put(key, value); > > So I think this could have been caused by issue 2238 > (Avoid a slow exception catch in JdkMapAdapterStringMap constructor #2238).
Thank you for reporting the issue. Can you add an excerpt of your Log4j Core configuration and the OS you are using? As far as I can see from the code issue #2238 affects configurations that use a DynamicThresholdFilter or ThreadContextMapFilter as global filter or use a ContextMapLookup. Other parts could be affected, but only if log events are generated. This does not occur for disabled log events, so only the two logged events might be slower. Piotr PS: I created PR #2256 to fix issue #2238: https://github.com/apache/logging-log4j2/pull/2256