[logback-dev] svn commit: r2169 - in logback/trunk/logback-classic/src: main/java/ch/qos/logback/classic test/java/ch/qos/logback/classic

noreply.ceki at qos.ch noreply.ceki at qos.ch
Tue Feb 24 10:40:18 CET 2009


Author: ceki
Date: Tue Feb 24 10:40:17 2009
New Revision: 2169

Modified:
   logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/Logger.java
   logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/LoggerContextTest.java

Log:
Fixing problem by the fact that the localLevelReset() method in the Logger class 
inadvertently uses the DEBUG_INT value in the org.slf4j.spi.LocationAwareLogger 
interface instead of the DEBUG_INT value in ch.qos.logback.classic.Level class. 

The issue was first identified by Andy Ruch in a message to the logback-user list
  http://qos.ch/pipermail/logback-user/2009-February/000955.html

Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/Logger.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/Logger.java	(original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/Logger.java	Tue Feb 24 10:40:17 2009
@@ -153,13 +153,13 @@
       // nothing to do;
       return;
     }
+    if(newLevel == null && isRootLogger()) {
+      throw new IllegalArgumentException("The level of the root logger cannot be set to null");
+    }
+        
     level = newLevel;
     if (newLevel == null) {
-      if (isRootLogger()) {
-        throw new IllegalArgumentException("The level of the root logger cannot be set to null");
-      } else {
-        effectiveLevelInt = parent.effectiveLevelInt;
-      }
+      effectiveLevelInt = parent.effectiveLevelInt;
     } else {
       effectiveLevelInt = newLevel.levelInt;
     }
@@ -322,7 +322,7 @@
   }
 
   private void localLevelReset() {
-    effectiveLevelInt = DEBUG_INT;
+    effectiveLevelInt = Level.DEBUG_INT;
     if(isRootLogger()) {
       level = Level.DEBUG;
     } else {

Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/LoggerContextTest.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/LoggerContextTest.java	(original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/LoggerContextTest.java	Tue Feb 24 10:40:17 2009
@@ -170,6 +170,7 @@
     root.setLevel(Level.INFO);
     lc.reset();
     assertEquals(Level.DEBUG, root.getEffectiveLevel());
+    assertTrue(root.isDebugEnabled());
     assertEquals(Level.DEBUG, a.getEffectiveLevel());
     assertEquals(Level.DEBUG, ab.getEffectiveLevel());
     
@@ -188,4 +189,15 @@
     lc.reset();
     assertFalse(nopTF.isStarted());
   }
+  
+  @Test
+  public void levelResetTest() {
+    Logger root = lc.getLogger(LoggerContext.ROOT_NAME);
+    root.setLevel(Level.TRACE);
+    assertTrue(root.isTraceEnabled());
+    lc.reset();
+    assertFalse(root.isTraceEnabled());
+    assertTrue(root.isDebugEnabled());
+  }
+  
 }
\ No newline at end of file


More information about the logback-dev mailing list