Add ThreadContextStack injection capability#3810
Conversation
- Add ThreadContextStackFactory following ThreadContextMapFactory pattern - Extend Provider class with ThreadContextStack support (backward compatible) - Add NOOP_STACK constant to ThreadContext - Support log4j2.threadContextStack system property - Add comprehensive tests - Update package version for BND compliance Fixes apache#1507
|
@yybmion, do you have a use case? Do you need this functionality for a certain system of yours that is deployed to production? Would you mind giving us some more context, please? |
|
Hi @vy, Thank you for the question! You previously provided positive feedback on this issue, stating:
I understand your concern about whether this is truly essential functionality. You're absolutely right that many use cases can be implemented using custom That said, I approached this change from two angles: 1. Architectural ConsistencyAs you previously noted, 2. Purpose-Driven Use CasesWhile
So while this feature may not be strictly required in the minimal sense, I think it adds clarity and purpose-driven extensibility that complements the existing I believe this aligns with the design vision you described, and I'd be happy to discuss this further if you have additional concerns. Best regards |
|
@yybmion, I am sorry to inform you that I will close this PR as not planned. This is sort of an exotic feature; neither the original reporter in #1507 responded to my question of whether they still need it. I really appreciate your effort and I don't want it to be for nothing, hence I cloned your branch to feature/2.x/thread-context-stack-service-loader in case we might need to revise this decision in the future. That said, with the current lack of interest, we're not inclined to extend the current API surface. |
|
Thanks for the update and for keeping the branch. I understand the decision. |
Implements custom
ThreadContextStackinjection capability as requested in #1507.Users can now inject custom
ThreadContextStackimplementations just likeThreadContextMap.Changes
NOOP_STACKconstant and updated initialization logiclog4j2.threadContextStack=com.example.MyCustomStacklog4j2.component.propertiesChecklist
✅ Required checks
License: I confirm that my changes are submitted under the Apache License, Version 2.0.
Commit signatures: All commits are signed and verifiable. (See GitHub Docs on Commit Signature Verification).
Code formatting: The code is formatted according to the project’s style guide.
How to check and fix formatting
./mvnw spotless:check./mvnw spotless:applySee the build instructions for details.
Build & Test: I verified that the project builds and all unit tests pass.
How to build the project
Run:
./mvnw verifySee the build instructions for details.
🧪 Tests (select one)
📝 Changelog (select one)
src/changelog/.2.x.x. (See Changelog Entry File Guide).fixes #1507