Get rid of log4j "not initialized" messages.
authorwassa <wassa@ab3bd59b-922f-494d-bb5f-6f0a3c29deca>
Mon, 3 May 2004 21:30:59 +0000 (21:30 +0000)
committerwassa <wassa@ab3bd59b-922f-494d-bb5f-6f0a3c29deca>
Mon, 3 May 2004 21:30:59 +0000 (21:30 +0000)
git-svn-id: https://subversion.switch.ch/svn/shibboleth/java-idp/trunk@1047 ab3bd59b-922f-494d-bb5f-6f0a3c29deca

src/edu/internet2/middleware/shibboleth/utils/MetadataTool.java

index d999b15..f7e742a 100644 (file)
@@ -55,6 +55,10 @@ import java.io.*;
 import java.security.*;
 import java.security.cert.Certificate;
 import java.security.cert.*;
+import org.apache.log4j.ConsoleAppender;
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+import org.apache.log4j.PatternLayout;
 import org.apache.xml.security.c14n.*;
 import org.apache.xml.security.signature.*;
 import org.apache.xml.security.transforms.*;
@@ -110,6 +114,9 @@ public class MetadataTool
             printUsage(System.out);
             System.exit(0);
         }
+
+
+               configureLogging(false);
         
         Boolean sign = (Boolean)parser.getOptionValue(signOption);
         Boolean noverify = (Boolean)parser.getOptionValue(noverifyOption);
@@ -260,5 +267,22 @@ public class MetadataTool
         out.println();
         System.exit(1);
     }
+       
+       private static void configureLogging(boolean debugEnabled) {
+               ConsoleAppender rootAppender = new ConsoleAppender();
+               rootAppender.setWriter(new PrintWriter(System.out));
+               rootAppender.setName("stdout");
+               Logger.getRootLogger().addAppender(rootAppender);
+
+               if (debugEnabled) {
+                       Logger.getRootLogger().setLevel(Level.DEBUG);
+                       rootAppender.setLayout(new PatternLayout("%-5p %-41X{serviceId} %d{ISO8601} (%c:%L) - %m%n")); 
+               } else {
+                       Logger.getRootLogger().setLevel(Level.INFO);
+                       Logger.getLogger("edu.internet2.middleware.shibboleth.aa.attrresolv").setLevel(Level.WARN);
+                       rootAppender.setLayout(new PatternLayout(PatternLayout.TTCC_CONVERSION_PATTERN)); 
+               }
+               Logger.getLogger("org.apache.xml.security").setLevel(Level.OFF);
+       }
 }