sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fmesc...@apache.org
Subject svn commit: r1232897 - /sling/trunk/bundles/commons/log/src/main/java/org/apache/sling/commons/log/internal/Activator.java
Date Wed, 18 Jan 2012 14:20:54 GMT
Author: fmeschbe
Date: Wed Jan 18 14:20:53 2012
New Revision: 1232897

URL: http://svn.apache.org/viewvc?rev=1232897&view=rev
Log:
SLING-2373 Unless explicit configuration file or configurator is set in system properties,
a dummy configurator is configured and log manager is forced to read it.

Modified:
    sling/trunk/bundles/commons/log/src/main/java/org/apache/sling/commons/log/internal/Activator.java

Modified: sling/trunk/bundles/commons/log/src/main/java/org/apache/sling/commons/log/internal/Activator.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/commons/log/src/main/java/org/apache/sling/commons/log/internal/Activator.java?rev=1232897&r1=1232896&r2=1232897&view=diff
==============================================================================
--- sling/trunk/bundles/commons/log/src/main/java/org/apache/sling/commons/log/internal/Activator.java
(original)
+++ sling/trunk/bundles/commons/log/src/main/java/org/apache/sling/commons/log/internal/Activator.java
Wed Jan 18 14:20:53 2012
@@ -39,6 +39,22 @@ public class Activator implements Bundle
         logManager = new LogManager(context);
 
         if (Boolean.parseBoolean(context.getProperty(JUL_SUPPORT))) {
+
+            // make sure configuration is empty unless explicitly set
+            if (System.getProperty("java.util.logging.config.file") == null
+                && System.getProperty("java.util.logging.config.class") == null)
{
+                final Thread ct = Thread.currentThread();
+                final ClassLoader old = ct.getContextClassLoader();
+                try {
+                    ct.setContextClassLoader(getClass().getClassLoader());
+                    System.setProperty("java.util.logging.config.class",
+                        "org.apache.sling.commons.log.internal.Activator.DummyLogManagerConfiguration");
+                    java.util.logging.LogManager.getLogManager().reset();
+                } finally {
+                    ct.setContextClassLoader(old);
+                }
+            }
+
             SLF4JBridgeHandler.install();
         }
     }
@@ -54,4 +70,13 @@ public class Activator implements Bundle
             logManager = null;
         }
     }
+
+    /**
+     * The <code>DummyLogManagerConfiguration</code> class is used as
+     * JUL LogginManager configurator to preven reading platform default
+     * configuration which just duplicate log output to be redirected to
+     * SLF4J.
+     */
+    public static class DummyLogManagerConfiguration {
+    }
 }



Mime
View raw message