-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Add API to list supported configuration file extensions #3839
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
base: 2.x
Are you sure you want to change the base?
Conversation
Hi @ppkarwasz , Just a gentle reminder — PTAL when you have time. |
log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationFactory.java
Outdated
Show resolved
Hide resolved
log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationFactory.java
Outdated
Show resolved
Hide resolved
@ppkarwasz, would you mind reminding me why we decided to introduce a new API such that
Put another way, why don't we add a static |
Totally agree. Let’s put a default implementation in @Override
public List<String> getSupportedExtensions() {
final String[] types = getSupportedTypes(); // protected, legacy API
// Preserve legacy semantics: only advertise extensions when active and types are present.
return isActive() && types != null && types.length > 0
? Arrays.asList(types)
: Collections.emptyList();
}
I prefer the dedicated
|
Add getSupportedExtensions() methods to allow external frameworks like Spring Boot to determine which configuration file formats are currently supported at runtime. - Add abstract getSupportedExtensions() method to ConfigurationFactory - Implement getSupportedExtensions() in all ConfigurationFactory subclasses - Add comprehensive test closes apache#3775
Please don't – you will still end up having two methods doing the same thing.
Agreed. Let's make
What you're describing is not a problem, but a behavior and it is all good, AFAICT. It is up to the
That is a good idea.
|
Another concern I have regarding adding a new, as a matter of fact, 2nd after On Tuesday, in a meeting where @ppkarwasz and I were present, after hearing that one of the biggest Log4j users using programmatic configuration extensively, I am very reluctant to marry the concept of files with configurations. |
The inconsistency is in the way a factory communicates that it is inactive:
My point is that, as they are now implemented, it does not make sense to make these methods public.
I agree completely: a
I don’t think we should make either
Alternative proposalLooking again at If we take a step back, Spring Boot doesn’t actually need to know about multiple factories, or how we handle extensions and precedence. What it needs boils down to:
TL;DR: @yybmion, apologies that your PR turned into a broader discussion about |
Summary
Add ConfigurationFactory.getActiveFileExtensions() and getSupportedExtensions() methods to allow external frameworks like Spring Boot to determine which configuration file formats are currently supported at runtime.
Example Usage
closes #3775
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).