tvand commented on code in PR #120:
URL: https://github.com/apache/commons-jcs/pull/120#discussion_r1039756273
##########
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:
I was thinking something in the lines of System.err.println(e.getMessage());
for every error in the list.
The stack trace is not interesting because it is the same for every error.
--
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]