Load log4j properties/xml configuration with the ShibResource class.
authorwassa <wassa@ab3bd59b-922f-494d-bb5f-6f0a3c29deca>
Thu, 19 May 2005 19:16:17 +0000 (19:16 +0000)
committerwassa <wassa@ab3bd59b-922f-494d-bb5f-6f0a3c29deca>
Thu, 19 May 2005 19:16:17 +0000 (19:16 +0000)
git-svn-id: https://subversion.switch.ch/svn/shibboleth/java-idp/trunk@1541 ab3bd59b-922f-494d-bb5f-6f0a3c29deca

src/edu/internet2/middleware/shibboleth/log/LoggingInitializer.java

index 2a21f3a..17c0e69 100644 (file)
@@ -25,8 +25,7 @@
 
 package edu.internet2.middleware.shibboleth.log;
 
-import java.net.MalformedURLException;
-import java.net.URL;
+import java.io.IOException;
 
 import org.apache.log4j.ConsoleAppender;
 import org.apache.log4j.DailyRollingFileAppender;
@@ -269,18 +268,21 @@ public class LoggingInitializer {
                        type = typeNode.getNodeValue();
                }
 
-               URL url;
+               ShibResource log4jConfig;
                try {
-                       url = new URL(location);
-               } catch (MalformedURLException e) {
+                       log4jConfig = new ShibResource(location);
+                       if (type == null || "properties".equals(type)) {
+                               PropertyConfigurator.configure(log4jConfig.getURL());
+                       } else if ("xml".equals(type)) {
+                               DOMConfigurator.configure(log4jConfig.getURL());
+                       } else {
+                               throw new ShibbolethConfigurationException(
+                                               "<Log4JConfig (type) attribute must be one of \"xml\" or \"properties\".");
+                       }
+               } catch (IOException e) {
                        throw new ShibbolethConfigurationException("<Log4JConfig location=\"" + location + "\">: not a valid URL: "
                                        + e);
                }
 
-               if (type == null || "properties".equals(type)) {
-                       PropertyConfigurator.configure(url);
-               } else if ("xml".equals(type)) {
-                       DOMConfigurator.configure(url);
-               }
        }
 }
\ No newline at end of file