[LOGBack-dev] svn commit: r269 - logback/classic/trunk/src/main/java/ch/qos/logback/classic

noreply.seb at qos.ch noreply.seb at qos.ch
Tue Jul 25 10:37:55 CEST 2006


Author: seb
Date: Tue Jul 25 10:37:54 2006
New Revision: 269

Modified:
   logback/classic/trunk/src/main/java/ch/qos/logback/classic/LoggerContext.java
Log:
Context now adds an error if no appender is in the hierarchy

Modified: logback/classic/trunk/src/main/java/ch/qos/logback/classic/LoggerContext.java
==============================================================================
--- logback/classic/trunk/src/main/java/ch/qos/logback/classic/LoggerContext.java	(original)
+++ logback/classic/trunk/src/main/java/ch/qos/logback/classic/LoggerContext.java	Tue Jul 25 10:37:54 2006
@@ -15,6 +15,7 @@
 
 import ch.qos.logback.core.ContextBase;
 import ch.qos.logback.core.CoreGlobal;
+import ch.qos.logback.core.status.ErrorStatus;
 
 
 /**
@@ -24,6 +25,7 @@
 
   private Logger root;
   private int size;
+  private int noAppenderWarning = 0;
   
   // We want loggerCache to be synchronized so Hashtable is a good choice. In practice, it 
   // performs a little faster than the map returned by Collections.synchronizedMap at the 
@@ -103,6 +105,12 @@
    */
   Logger exists(String name) {
     return (Logger) loggerCache.get(name);
-
+  }
+  
+  final void noAppenderDefinedWarning(final Logger logger) {
+  	 if (noAppenderWarning++ == 0) {
+  	      getStatusManager().add(new ErrorStatus(
+	        "No appenders present in the hierarchy ["+ getName() +"] for logger [" + logger.getName() + "].", logger));
+  	 }
   }
 }



More information about the logback-dev mailing list