yybmion commented on issue #3775:
URL: 
https://github.com/apache/logging-log4j2/issues/3775#issuecomment-3088337699

   Thanks for guidance @ppkarwasz!
   Based on the discussion above, I'm proposing to add this static method to 
ConfigurationFactory
   ```java
   /**
    * Returns configuration file extensions currently supported at runtime.
    * This can be used by external frameworks like Spring Boot for 
configuration file discovery logic.
    *
    * <p>This method checks all active ConfigurationFactory instances and 
returns only the file formats
    * that are actually available. For example, if the Jackson library is 
missing, JSON formats
    * will be excluded from the results.</p>
    *
    * @return array of supported file extensions (e.g., ["xml", "json", 
"properties"])
    * @since 2.25.0
    */
   public static String[] getSupportedConfigurationExtensions() {
       final List<String> extensions = new ArrayList<>();
       for (final ConfigurationFactory factory : getFactories()) {
           if (factory.isActive()) {
               final String[] types = factory.getSupportedTypes();
               if (types != null) {
                   for (final String type : types) {
                       if (!"*".equals(type) && !extensions.contains(type)) {
                           extensions.add(type);
                       }
                   }
               }
           }
       }
       return extensions.toArray(new String[0]);
   }
   ```
   
   Implementation approach:
   
   - Filters results from getFactories() to include only active factories
   - Leverages existing getSupportedTypes() and isActive() methods
   - Excludes wildcard types ("*") that aren't meaningful as file extensions
   - Avoids duplicates in the result array
   
   Does this implementation approach look correct to you?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to