Documentation Update for Logger Layout Pattern Precision Example #3744
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Correct logger precision example.
The current example is incorrect.
%c{1.2.*}
does not returno.a.commons.test.Foo
due to the extra period before*
, instead, it will use1.2
as the pattern and showso.ap.commons.Foo
To get the output
o.a.commons.test.Foo
, the formatter needs to be%c{1.3*}
where the3*
indicates number of right most token to be printed in full. (bullet point 2 in the doc)%c{1.1*}
org.apache.commons.Foo
o.a.c.Foo
%c{1.1.*}
org.apache.commons.Foo
o.a.commons.Foo
%c{1.2*}
org.apache.commons.Foo
o.a.commons.Foo
%c{1.2.*}
org.apache.commons.Foo
o.ap.commons.Foo
I do have a question/issue? where that logic only works if the number before the first period is 1, so
%c{1.1*}
>>o.a.c.Foo
%c{1.2*}
>>o.a.commons.Foo
%c{1.3*}
>>o.apache.commons.Foo
works, but
%c{2.1*}
>>or.a*.c*.Foo
%c{2.2*}
>>or.ap*.co*.Foo
%c{2.3*}
>>or.apa*.com*.Foo
does not work as expected.
Important
Base your changes on
2.x
branch if you are targeting Log4j 2; usemain
otherwise.Checklist
Before we can review and merge your changes, please go through the checklist below. If you're still working on some items, feel free to submit your pull request as a draft—our CI will help guide you through the remaining steps.
✅ 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:apply
See 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 verify
See the build instructions for details.
🧪 Tests (select one)
📝 Changelog (select one)
src/changelog/.2.x.x
. (See Changelog Entry File Guide).