jeremylong commented on code in PR #120:
URL: https://github.com/apache/commons-jcs/pull/120#discussion_r1038874081
##########
commons-jcs-core/src/main/java/org/apache/commons/jcs3/log/LogManager.java:
##########
@@ -57,15 +61,34 @@ private static LogFactory createLogFactory()
LogManager.logSystem = System.getProperty("jcs.logSystem",
LOGSYSTEM_JAVA_UTIL_LOGGING);
}
-
- for (final LogFactory factory : factories)
- {
- if (logSystem.equalsIgnoreCase(factory.getName()))
- {
- return factory;
+ List<ServiceConfigurationError> errors = new ArrayList<>();
+ Iterator<LogFactory> itr = factories.iterator();
+ LogFactory factory = null;
+ while (itr.hasNext()) {
+ try {
+ LogFactory instance = itr.next();
+ if (logSystem.equalsIgnoreCase(instance.getName())) {
+ factory = instance;
+ break;
+ }
+ } catch (ServiceConfigurationError e) {
+ errors.add(e);
}
}
-
+ if (factory != null) {
+ if (!errors.isEmpty()) {
+ Log log = factory.getLog(LogFactoryHolder.class);
+ for (ServiceConfigurationError error : errors) {
+ log.debug("Error loading LogFactory", error);
+ }
+ log.debug("Found LogFacgtory for " + logSystem);
+ }
+ return factory;
+ }
+ if (!errors.isEmpty()) {
+ throw new RuntimeException("Could not find factory
implementation for log subsystem " + logSystem,
+ errors.get(0));
Review Comment:
After re-looking at the code - where do you suggest we print out the
exceptions (standard err?)? No logger was identified - so we don't have a good
way to combine more then one exception as we do not have a logger to print each
out... We could combine the messages, but the full stack trace would be
difficult.
--
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]