-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Remove log4j2.enable.threadlocals property
#2171
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
589304f to
7177c1f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Amazing diff!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is something I don't understand about this PR: we do want a ThreadLocalRecyclerFactoryProvider out-of-the-box.
But we want to be enabled/disabled using the Recycler.factory = "threadLocal" and Recycler.factory = "dummy" properties.
It's great you removed all the trailing ThreadLocal instances, but I think you should restore the ThreadLocalRecyclerFactory.
I am not sure what recycler factory should be the default one though: Spring Boot applications usually contain a Servlet API, but have only a single app running, so a default of threadLocal sounds good to me. If there is a way to detect the usage of virtual threads, we could switch the default to "dummy".
log4j-api/src/main/java/org/apache/logging/log4j/message/MessageFactory.java
Outdated
Show resolved
Hide resolved
|
@ppkarwasz, I don't think you want a thread local recycler. 😜 In the face of virtual threads, thread locals are a risky liability. As a matter of fact, they already were actually; hence, several "if not running in a web application", "if only using JDK classes", etc. guards surrounding them. The new default, the queueing recycler, is almost as good as the thread local recycler. Those who need more efficiency, can use |
|
@ppkarwasz, I placed the thread local recycler back. I want to move on with this PR. |
|
LGTM |
|
I didn't see any of the doc files listed in the PR. If the property was removed it should be removed from the documentation as well. |
Fixed in e6044c9. |
This PR addresses #2105 and removes
log4j2.enable.threadlocalsproperty. While doing so, following major changes are also implemented:ThreadLocal-based recycler is removedParametrizedMessageFactoryis removed – switched toReusableMessageFactoryeverywhereThreadNameCachingStrategyis removed – Java 17 renders it redundantDefaultThreadContextMapis removed – Other implementations serve fine with recyclers, which don't have anyThreadLocalissues anymore. Weirdly enough,DefaultThreadContextMap, which is the fallback used when thread locals are disabled, was using thread locals too.Question: Similar to
ParametrizedMessageFactory, I doubt ifDefaultLogEventFactorymakes sense anymore. Can we make theReusableLogEventFactorydefault instead?