geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r438786 - in /geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/log: BootstrapJdk14Log.java BootstrapLog4jLog.java GeronimoLogging.java
Date Thu, 31 Aug 2006 04:35:25 GMT
Author: jdillon
Date: Wed Aug 30 21:35:25 2006
New Revision: 438786

URL: http://svn.apache.org/viewvc?rev=438786&view=rev
Log:
Only initialize bootstrap log impls in static block if the geronimo.bootstrap.logging.enabled
sys prop is not set to false
This allows tests to use one logging configuration to control log output

Modified:
    geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/log/BootstrapJdk14Log.java
    geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/log/BootstrapLog4jLog.java
    geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/log/GeronimoLogging.java

Modified: geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/log/BootstrapJdk14Log.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/log/BootstrapJdk14Log.java?rev=438786&r1=438785&r2=438786&view=diff
==============================================================================
--- geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/log/BootstrapJdk14Log.java
(original)
+++ geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/log/BootstrapJdk14Log.java
Wed Aug 30 21:35:25 2006
@@ -25,34 +25,38 @@
 import org.apache.commons.logging.Log;
 
 /**
+ * Bootstrap log implementation for use with JDK 1.4 logging.
+ *
  * @version $Rev$ $Date$
  */
 public class BootstrapJdk14Log implements Log {
     static {
-        Logger root = Logger.getLogger("");
+        if (GeronimoLogging.isBootstrapLoggingInitializationEnabled()) {
+            Logger root = Logger.getLogger("");
 
-        GeronimoLogging geronimoLevel = GeronimoLogging.getDefaultLevel();
-        Level javaLevel;
-        if (geronimoLevel == GeronimoLogging.TRACE) {
-            javaLevel = Level.FINEST;
-        } else if (geronimoLevel == GeronimoLogging.DEBUG) {
-            javaLevel = Level.FINE;
-        } else if (geronimoLevel == GeronimoLogging.INFO) {
-            javaLevel = Level.INFO;
-        } else if (geronimoLevel == GeronimoLogging.WARN) {
-            javaLevel = Level.WARNING;
-        } else {
-            javaLevel = Level.SEVERE;
-        }
+            GeronimoLogging geronimoLevel = GeronimoLogging.getDefaultLevel();
+            Level javaLevel;
+            if (geronimoLevel == GeronimoLogging.TRACE) {
+                javaLevel = Level.FINEST;
+            } else if (geronimoLevel == GeronimoLogging.DEBUG) {
+                javaLevel = Level.FINE;
+            } else if (geronimoLevel == GeronimoLogging.INFO) {
+                javaLevel = Level.INFO;
+            } else if (geronimoLevel == GeronimoLogging.WARN) {
+                javaLevel = Level.WARNING;
+            } else {
+                javaLevel = Level.SEVERE;
+            }
 
-        // set the root level
-        root.setLevel(javaLevel);
+            // set the root level
+            root.setLevel(javaLevel);
 
-        // set the console handler level (if present)
-        Handler[] handlers = root.getHandlers();
-        for (int index = 0; index < handlers.length; index++) {
-            if (handlers[index] instanceof ConsoleHandler) {
-                handlers[index].setLevel(javaLevel);
+            // set the console handler level (if present)
+            Handler[] handlers = root.getHandlers();
+            for (int index = 0; index < handlers.length; index++) {
+                if (handlers[index] instanceof ConsoleHandler) {
+                    handlers[index].setLevel(javaLevel);
+                }
             }
         }
     }

Modified: geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/log/BootstrapLog4jLog.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/log/BootstrapLog4jLog.java?rev=438786&r1=438785&r2=438786&view=diff
==============================================================================
--- geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/log/BootstrapLog4jLog.java
(original)
+++ geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/log/BootstrapLog4jLog.java
Wed Aug 30 21:35:25 2006
@@ -24,30 +24,33 @@
 import org.apache.log4j.PatternLayout;
 
 /**
+ * Bootstrap log implementation for use with Log4j.
+ *
  * @version $Rev$ $Date$
  */
 public class BootstrapLog4jLog implements Log {
     static {
-        Logger root = Logger.getRootLogger();
-        root.addAppender(new ConsoleAppender(new PatternLayout("%d{ABSOLUTE} %-5p [%c{1}]
%m%n")));
+        if (GeronimoLogging.isBootstrapLoggingInitializationEnabled()) {
+            Logger root = Logger.getRootLogger();
+            root.addAppender(new ConsoleAppender(new PatternLayout("%d{ABSOLUTE} %-5p [%c{1}]
%m%n")));
 
-        GeronimoLogging level = GeronimoLogging.getDefaultLevel();
-        if (level == null) {
-            root.setLevel(Level.ERROR);
-        } else if (level == GeronimoLogging.TRACE) {
-            root.setLevel(Level.DEBUG);
-        } else if (level == GeronimoLogging.DEBUG) {
-            root.setLevel(Level.DEBUG);
-        } else if (level == GeronimoLogging.INFO) {
-            root.setLevel(Level.INFO);
-        } else if (level == GeronimoLogging.WARN) {
-            root.setLevel(Level.WARN);
-        } else if (level == GeronimoLogging.ERROR) {
-            root.setLevel(Level.ERROR);
-        } else if (level == GeronimoLogging.FATAL) {
-            root.setLevel(Level.FATAL);
+            GeronimoLogging level = GeronimoLogging.getDefaultLevel();
+            if (level == null) {
+                root.setLevel(Level.ERROR);
+            } else if (level == GeronimoLogging.TRACE) {
+                root.setLevel(Level.DEBUG);
+            } else if (level == GeronimoLogging.DEBUG) {
+                root.setLevel(Level.DEBUG);
+            } else if (level == GeronimoLogging.INFO) {
+                root.setLevel(Level.INFO);
+            } else if (level == GeronimoLogging.WARN) {
+                root.setLevel(Level.WARN);
+            } else if (level == GeronimoLogging.ERROR) {
+                root.setLevel(Level.ERROR);
+            } else if (level == GeronimoLogging.FATAL) {
+                root.setLevel(Level.FATAL);
+            }
         }
-
     }
 
     private static final String FQCN = BootstrapLog4jLog.class.getName();

Modified: geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/log/GeronimoLogging.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/log/GeronimoLogging.java?rev=438786&r1=438785&r2=438786&view=diff
==============================================================================
--- geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/log/GeronimoLogging.java
(original)
+++ geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/log/GeronimoLogging.java
Wed Aug 30 21:35:25 2006
@@ -42,7 +42,6 @@
     private static GeronimoLogging consoleLogLevel = ERROR;
     private static GeronimoLogging defaultLevel;
 
-
     /**
      * Initializes the logging system used by Geronimo.  This MUST be called in
      * in the main class used to start the geronimo server.  This method forces
@@ -84,7 +83,6 @@
         return defaultLevel;
     }
 
-
     public static GeronimoLogging getConsoleLogLevel() {
         return consoleLogLevel;
     }
@@ -106,5 +104,23 @@
 
     public String toString() {
         return level;
+    }
+
+    /**
+     * Check if the Geronimo bootstrap logging initialization is enabled.
+     *
+     * <p>Checks the system property <tt>geronimo.bootstrap.logging.enabled</tt>
+     * if not set, or set to "true" then bootstrap logging initialization is enabled.
+     *
+     * @return  True of bootstrap logging initialization is enabled.
+     */
+    public static boolean isBootstrapLoggingInitializationEnabled() {
+        String value = System.getProperty("geronimo.bootstrap.logging.enabled");
+        if (value == null) {
+            return true;
+        }
+        else {
+            return Boolean.valueOf(value).booleanValue();
+        }
     }
 }



Mime
View raw message