[slf4j-dev] svn commit: r1244 - in slf4j/trunk: jul-to-slf4j/src/main/java/org/slf4j/bridge slf4j-site/src/site/pages

ceki at slf4j.org ceki at slf4j.org
Thu Nov 20 15:59:28 CET 2008


Author: ceki
Date: Thu Nov 20 15:59:28 2008
New Revision: 1244

Modified:
   slf4j/trunk/jul-to-slf4j/src/main/java/org/slf4j/bridge/SLF4JBridgeHandler.java
   slf4j/trunk/slf4j-site/src/site/pages/news.html

Log:
The install() method of SLF4JBridgeHandler will no longer reset the entire
j.u.l. environment but solely add a SLF4JBridgeHandler instance to jul's root logger. 
By the same token, the uninstall() method will remove previously added
SLF4JBridgeHandler instances without making any other modifications to the j.u.l. 
configuration.
  

Modified: slf4j/trunk/jul-to-slf4j/src/main/java/org/slf4j/bridge/SLF4JBridgeHandler.java
==============================================================================
--- slf4j/trunk/jul-to-slf4j/src/main/java/org/slf4j/bridge/SLF4JBridgeHandler.java	(original)
+++ slf4j/trunk/jul-to-slf4j/src/main/java/org/slf4j/bridge/SLF4JBridgeHandler.java	Thu Nov 20 15:59:28 2008
@@ -31,7 +31,6 @@
 
 package org.slf4j.bridge;
 
-import java.io.IOException;
 import java.text.MessageFormat;
 import java.util.MissingResourceException;
 import java.util.ResourceBundle;
@@ -95,37 +94,37 @@
   private static final int WARN_LEVEL_THRESHOLD = Level.WARNING.intValue();
 
   /**
-   * Resets the entire JUL logging system and adds new SLF4JHandler instance to
-   * the root logger.
+   * Adds a SLF4JBridgeHandler instance to jul's root logger.
+   * 
+   * <p>
+   * This handler will redirect jul logging to SLF4J. However, only logs enabled
+   * in j.u.l. will be redirected. For example, if a log statement invoking a
+   * j.u.l. logger disabled that statement, by definition, will <em>not</em> reach
+   * any SLF4JBridgeHandler instance and cannot be redirected. 
    */
   public static void install() {
-    LogManager.getLogManager().reset();
     LogManager.getLogManager().getLogger("").addHandler(
         new SLF4JBridgeHandler());
   }
 
   /**
-   * Rereads the JUL configuration.
-   * 
-   * @see LogManager#readConfiguration()
+   * Removes previously installed SLF4JBridgeHandler instances. See also
+   * {@link #install()}.
    * 
-   * @throws IOException
-   *                 <code>IOException</code> if there are IO problems reading
-   *                 the configuration.
    * @throws SecurityException
    *                 A <code>SecurityException</code> is thrown, if a security
    *                 manager exists and if the caller does not have
    *                 LoggingPermission("control").
    */
-  public static void uninstall() throws SecurityException, IOException {
-    java.util.logging.Logger rootLogger = LogManager.getLogManager().getLogger("");
+  public static void uninstall() throws SecurityException {
+    java.util.logging.Logger rootLogger = LogManager.getLogManager().getLogger(
+        "");
     Handler[] handlers = rootLogger.getHandlers();
-    for(int i = 0; i < handlers.length; i++) {
-      if(handlers[i] instanceof SLF4JBridgeHandler) {
+    for (int i = 0; i < handlers.length; i++) {
+      if (handlers[i] instanceof SLF4JBridgeHandler) {
         rootLogger.removeHandler(handlers[i]);
       }
     }
-    LogManager.getLogManager().readConfiguration();
   }
 
   /**

Modified: slf4j/trunk/slf4j-site/src/site/pages/news.html
==============================================================================
--- slf4j/trunk/slf4j-site/src/site/pages/news.html	(original)
+++ slf4j/trunk/slf4j-site/src/site/pages/news.html	Thu Nov 20 15:59:28 2008
@@ -31,7 +31,7 @@
   <h3>November 21st, 2008 - Release of SLF4J 1.5.6</h3>
 
   <p>Fixed long standing <a
-  href="http://bugzilla.slf4j.org/show_bug.cgi?id=84">bug 84</a> and
+  href="http://jira.qos.ch/browse/LBCLASSIC-87">LBCLASSIC-87</a> and
   its younger sibling <a
   href="http://bugzilla.slf4j.org/show_bug.cgi?id=113">bug
   113</a>. With each call to getLogger() method,
@@ -48,9 +48,20 @@
   location information.
   </p>
 
-  <p>Added MDCStrLookup to slf4j-ext. This class can be used with Apache
-  Commons Lang's StrSubstitutor class to inject values in the SLF4J MDC
-  into strings. Information on StrSubstitutor can be found at <a
+  
+  <p>The <code>install()</code> method of
+  <code>SLF4JBridgeHandler</code> will no longer reset the entire
+  j.u.l. environment but solely add a <code>SLF4JBridgeHandler</code>
+  instance to jul's root logger. By the same token, the
+  <code>uninstall()</code> method will remove previously added
+  <code>SLF4JBridgeHandler</code> instances without making any other
+  modifications to the j.u.l. configuration.
+  </p>
+  
+  <p>Added <code>MDCStrLookup</code> to slf4j-ext. This class can be
+  used with Apache Commons Lang's <code>StrSubstitutor</code> class to
+  inject values in the SLF4J MDC into strings. Information on
+  StrSubstitutor can be found at <a
   href="http://commons.apache.org/lang/api-release/org/apache/commons/lang/text/StrSubstitutor.html">StrSubstitutor
   javadoc</a>.
   </p>



More information about the slf4j-dev mailing list