You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by GitBox <gi...@apache.org> on 2022/12/03 21:23:13 UTC

[GitHub] [commons-jcs] jeremylong commented on a diff in pull request #120: fix: handle ServiceConfigurationError

jeremylong commented on code in PR #120:
URL: https://github.com/apache/commons-jcs/pull/120#discussion_r1038873332


##########
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);

Review Comment:
   At this point - we have already selected the logging system (i.e. factory is not null). I just added logging showing the issues with loading other loggers in debug.



-- 
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: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org