Skip to content
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

[LOG4J2-3413] Fixes resolution of non-Log4j properties #774

Merged
merged 1 commit into from
Feb 26, 2022

Conversation

ppkarwasz
Copy link
Contributor

For properties that does not start with log4j or org.apache.logging.log4j the loosed token-based lookup should not be
applied. There are a couple of exceptions to this rule: the properties that start with AsyncLogger and those related to
disableThreadContext.

This PR prevents properties such as level to be used as a substitute for log4j2.level

For properties that does not start with `log4j` or
`org.apache.logging.log4j` the loosed token-based lookup should not be
applied. There are a couple of exceptions to this rule: the properties
that start with `AsyncLogger` and those related to
`disableThreadContext`.

This PR prevents properties such as `level` to be used as a substitute
for `log4j2.level`
@ppkarwasz ppkarwasz changed the title [LOG4J-3413] Fixes resolution of non-Log4j properties [LOG4J2-3413] Fixes resolution of non-Log4j properties Feb 25, 2022
Copy link
Member

@jvz jvz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice update!

@ppkarwasz
Copy link
Contributor Author

Yes, I thought JIRA would link the PR automatically, but apparently it only checks the title provided at submission time.

Comment on lines +110 to +116
static {
// Add legacy properties without Log4j prefix
CACHE.put("disableThreadContext", Arrays.asList("disable", "thread", "context"));
CACHE.put("disableThreadContextStack", Arrays.asList("disable", "thread", "context", "stack"));
CACHE.put("disableThreadContextMap", Arrays.asList("disable", "thread", "context", "map"));
CACHE.put("isThreadContextMapInheritable", Arrays.asList("is", "thread", "context", "map", "inheritable"));
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are here just to satisfy LegacyPropertiesCompatibilityTest, which verifies that the tokenized version of the legacy and normalized properties are the same.

From the PropertiesUtil perspective they are not strictly necessary, since getStringProperty("disableThreadContext") will always look up at least the exact string "disableThreadContext" and it will retrieve the value before falling back to token-based comparison.

@jvz jvz merged commit 35f9db7 into apache:release-2.x Feb 26, 2022
@ppkarwasz ppkarwasz deleted the jira3413 branch February 26, 2022 22:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants