You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-cvs@jakarta.apache.org by ce...@apache.org on 2001/01/22 23:11:45 UTC

cvs commit: jakarta-log4j/org/apache/log4j/xml/test DisableOverrideTest.java Makefile

ceki        01/01/22 14:11:45

  Modified:    org/apache/log4j BasicConfigurator.java Category.java
                        Hierarchy.java PropertyConfigurator.java
               org/apache/log4j/performance NotLogging.java
               org/apache/log4j/test ShippedCodeFlagTest.java
                        UnitTestCategory.java
               org/apache/log4j/xml DOMConfigurator.java log4j.dtd
               org/apache/log4j/xml/examples XCategory.java
               org/apache/log4j/xml/test DisableOverrideTest.java Makefile
  Log:
  Logging can now be disabled per Hierarchy. It can also be disabled
  using configuration files using the "disable" directive.  The disableOverride
  directive takes precedence over the disable directive.  As a result of this change
  the disable family of methods has moved from the BasicConfigurator
  class to the Hierarchy class.
  
  Revision  Changes    Path
  1.8       +37 -142   jakarta-log4j/org/apache/log4j/BasicConfigurator.java
  
  Index: BasicConfigurator.java
  ===================================================================
  RCS file: /home/cvs/jakarta-log4j/org/apache/log4j/BasicConfigurator.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- BasicConfigurator.java	2001/01/20 16:02:18	1.7
  +++ BasicConfigurator.java	2001/01/22 22:11:24	1.8
  @@ -78,15 +78,11 @@
     static {    
       String override = OptionConverter.getSystemProperty(DISABLE_OVERRIDE_KEY, null);
       if(override != null) {
  -      if(OptionConverter.toBoolean(override, true)) {
  -	LogLog.debug("Overriding disable. Non-null system property " + 
  -		     DISABLE_OVERRIDE_KEY + "=[" + override +"].");
  -	Category.disable = Category.DISABLE_OVERRIDE;
  -      }
  +      Category.defaultHierarchy.setDisableOverride(override);
       } else { // check for log4j.disable only in absence of log4j.disableOverride
         String disableStr = OptionConverter.getSystemProperty(DISABLE_KEY, null);
         if(disableStr != null) {
  -	disableAsNeeded(disableStr);
  +	Category.defaultHierarchy.disable(disableStr);
         }
       }
     }
  @@ -144,142 +140,40 @@
       root.addAppender(appender);
     }
   
  -
  -  static
  -  protected
  -  void disableAsNeeded(String disableStr) {
  -    if((disableStr != null) && (Category.disable != Category.DISABLE_OVERRIDE)) {
  -      Priority p = Priority.toPriority(disableStr, null);
  -      if(p != null) {
  -	disable(p);
  -      } else {
  -	LogLog.warn("Could not convert ["+disableStr+"] to Priority.");
  -      }
  -    }
  -  }
  -
  -
  -  /**
  -     Disable all logging requests of priority <em>equal to or
  -     below</em> the priority parameter <code>p</code>, regardless of
  -     the request category. Logging requests of higher priority then
  -     the priority of <code>p</code> remain unaffected.
  -
  -     <p>Nevertheless, if the {@link #DISABLE_OVERRIDE_KEY} system
  -     property is set to "true" or any value other than "false", then
  -     logging requests are evaluated as usual, i.e. according to the <a
  -     href="../../manual.html#selectionRule">Basic Selection Rule</a>.
  -
  -     <p>The "disable" family of methods are there for speed. They
  -     allow printing methods such as debug, info, etc. to return
  -     immediately after an interger comparison without walking the
  -     category hierarchy. In most modern computers an integer
  -     comparison is measured in nanoseconds where as a category walk is
  -     measured in units of microseconds.
  -
  -     <p>Other configurators define alternate ways of overriding the
  -     disable override flag. See {@link PropertyConfigurator} and
  -     {@link org.apache.log4j.xml.DOMConfigurator}.
  -
  -
  -     @since 0.8.5 */
  -  static 
  -  public
  -  void disable(Priority p) {
  -    if(Category.disable != Category.DISABLE_OVERRIDE) {
  -      Category.disable = p.level;
  -    }
  -  }
  -  
     /**
  -     Disable all logging requests regardless of category and priority.
  -     This method is equivalent to calling {@link #disable} with the
  -     argument {@link Priority#FATAL}, the highest possible priority.
  -
  -     @since 0.8.5 */
  -  static 
  -  public
  -  void disableAll() {
  -    disable(Priority.FATAL);
  -  }
  -
  -
  -  /**
  -     Disable all logging requests of priority DEBUG regardless of
  -     category.  Invoking this method is equivalent to calling {@link
  -     #disable} with the argument {@link Priority#DEBUG}.
  -
  -     @since 0.8.5 */
  -  static 
  -  public
  -  void disableDebug() {
  -    disable(Priority.DEBUG);
  -  }
  -
  -
  -  /**
  -     Disable all logging requests of priority INFO and below
  -     regardless of category. Note that DEBUG messages are also
  -     disabled.  
  -
  -     <p>Invoking this method is equivalent to calling {@link #disable}
  -     with the argument {@link Priority#INFO}.
  -
  -     @since 0.8.5 */
  -  static 
  -  public
  -  void disableInfo() {
  -    disable(Priority.INFO);
  -  }  
  -
  -  /**
  -     Undoes the effect of calling any of {@link #disable}, {@link
  -     #disableAll}, {@link #disableDebug} and {@link #disableInfo}
  -     methods. More precisely, invoking this method sets the Category
  -     class internal variable called <code>disable</code> to its
  -     default "off" value.
  +     Reset the configuration to its default.  This removes all
  +     appenders from all categories, sets the priority of all non-root
  +     categories to <code>null</code>, their additivity flad to
  +     <code>true</code> and sets the priority of the root category to
  +     {@link Priority#DEBUG DEBUG}.  Moreover, message disabling is set
  +     its default "off" value.
   
  -     @since 0.8.5 */
  -  static 
  -  public
  -  void enableAll() {
  -    Category.disable = Category.DISABLE_OFF;
  -  }
  -  
  -  /**
  +     <p>This method should be used sparingly and with care as it will
  +     block all logging until it is completed.</p>
   
  -     This method is equivalent to the {@link #disableInfo} method.
  -     
  -     @deprecated
  -     @since 0.8.0 */
  +     @since version 0.8.5 */
     public
     static
  -  void flagAsShippedCode() {
  -    disableInfo();
  -  }
  -
  -
  -  /**
  -     Override the shipped code flag if the <code>override</code>
  -     parameter is not null.
  +  void resetConfiguration() {
   
  -     <p>If <code>override</code> is null then there is nothing to do.
  -     Otherwise, set Category.shippedCode to false if override has a
  -     value other than "false".     
  -  */
  -  protected
  -  static
  -  void overrideAsNeeded(String override) {
  -    // If override is defined, any value other than false will be
  -    // interpreted as true.    
  -    if(override != null) {
  -      LogLog.debug("Handling non-null disable override directive: \""+
  -		   override +"\".");
  -      if(OptionConverter.toBoolean(override, true)) {
  -	LogLog.debug("Overriding all disable methods.");
  -	Category.disable = Category.DISABLE_OVERRIDE;
  +    Category.defaultHierarchy.getRoot().setPriority(Priority.DEBUG);
  +    Category.defaultHierarchy.root.setResourceBundle(null);
  +    Category.defaultHierarchy.disable = Hierarchy.DISABLE_OFF;
  +    
  +    // the synchronization is needed to prevent JDK 1.2.x hashtable
  +    // surprises
  +    synchronized(Category.defaultHierarchy.ht) {    
  +      Category.defaultHierarchy.shutdown(); // nested locks are OK    
  +    
  +      Enumeration cats = Category.getCurrentCategories();
  +      while(cats.hasMoreElements()) {
  +	Category c = (Category) cats.nextElement();
  +	c.setPriority(null);
  +	c.setAdditivity(true);
  +	c.setResourceBundle(null);
         }
       }
  +    Category.defaultHierarchy.rendererMap.clear();
     }
   
     /**
  @@ -296,18 +190,18 @@
        @since version 0.8.5 */
     public
     static
  -  void resetConfiguration() {
  +  void resetConfiguration(Hierarchy hierarchy) {
   
  -    Category.defaultHierarchy.getRoot().setPriority(Priority.DEBUG);
  -    Category.defaultHierarchy.root.setResourceBundle(null);
  -    Category.disable =  Category.DISABLE_OFF;
  +    hierarchy.getRoot().setPriority(Priority.DEBUG);
  +    hierarchy.root.setResourceBundle(null);
  +    hierarchy.disable = Hierarchy.DISABLE_OFF;
       
       // the synchronization is needed to prevent JDK 1.2.x hashtable
       // surprises
  -    synchronized(Category.defaultHierarchy.ht) {    
  -      Category.defaultHierarchy.shutdown(); // nested locks are OK    
  +    synchronized(hierarchy.ht) {    
  +      hierarchy.shutdown(); // nested locks are OK    
       
  -      Enumeration cats = Category.getCurrentCategories();
  +      Enumeration cats = hierarchy.getCurrentCategories();
         while(cats.hasMoreElements()) {
   	Category c = (Category) cats.nextElement();
   	c.setPriority(null);
  @@ -315,6 +209,7 @@
   	c.setResourceBundle(null);
         }
       }
  -    Category.defaultHierarchy.rendererMap.clear();
  +    hierarchy.rendererMap.clear();
     }
  +
   }
  
  
  
  1.18      +21 -45    jakarta-log4j/org/apache/log4j/Category.java
  
  Index: Category.java
  ===================================================================
  RCS file: /home/cvs/jakarta-log4j/org/apache/log4j/Category.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- Category.java	2001/01/22 12:16:34	1.17
  +++ Category.java	2001/01/22 22:11:25	1.18
  @@ -51,22 +51,10 @@
     @author Anders Kristensen */
   public class Category implements AppenderAttachable {
   
  -  // DISABLE_OFF should be set to a value lower than all possible
  -  // priorities.
  -  static final int DISABLE_OFF = -1;
  -  static final int DISABLE_OVERRIDE = -2;
  -  
     private static String DEFAULT_FQN = "org.apache.log4j.Category";
   
     protected static String instanceFQN;
   
  -  // Don't disable any priority level by default.
  -  protected static int disable = Category.DISABLE_OFF;
  -
  -  static boolean emittedNoAppenderWarning = false;
  -  static boolean emittedNoResourceBundleWarning = false;  
  -
  -
     /**
        The hierarchy where categories are attached to by default.
     */
  @@ -261,11 +249,11 @@
         }
       }
       // No appenders in hierarchy, warn user only once.
  -    if(!Category.emittedNoAppenderWarning && writes == 0) {
  +    if(!hierarchy.emittedNoAppenderWarning && writes == 0) {
         LogLog.error("No appenders could be found for category (" +
   		    this.getName() + ").");
         LogLog.error("Please initialize the log4j system properly.");
  -      emittedNoAppenderWarning = true;
  +      hierarchy.emittedNoAppenderWarning = true;
       }
     }
   
  @@ -307,7 +295,7 @@
       @param message the message object to log. */
     public
     void debug(Object message) {
  -    if(disable >=  Priority.DEBUG_INT) 
  +    if(hierarchy.disable >=  Priority.DEBUG_INT) 
         return;    
       if(Priority.DEBUG.isGreaterOrEqual(this.getChainedPriority())) {
         forcedLog(instanceFQN, Priority.DEBUG, message, null);
  @@ -326,7 +314,7 @@
      @param t the exception to log, including its stack trace.  */  
     public
     void debug(Object message, Throwable t) {
  -    if(disable >=  Priority.DEBUG_INT) return;
  +    if(hierarchy.disable >=  Priority.DEBUG_INT) return;
       if(this.isEnabledFor(Priority.DEBUG))
         forcedLog(instanceFQN, Priority.DEBUG, message, t);
       
  @@ -361,7 +349,7 @@
       @param message the message object to log */
     public
     void error(Object message) {
  -    if(disable >=  Priority.ERROR_INT) return;
  +    if(hierarchy.disable >=  Priority.ERROR_INT) return;
       if(this.isEnabledFor(Priority.ERROR))
         forcedLog(instanceFQN, Priority.ERROR, message, null);
     }
  @@ -377,7 +365,7 @@
      @param t the exception to log, including its stack trace.  */  
     public
     void error(Object message, Throwable t) {
  -    if(disable >=  Priority.ERROR_INT) return;
  +    if(hierarchy.disable >=  Priority.ERROR_INT) return;
       if(this.isEnabledFor(Priority.ERROR))
         forcedLog(instanceFQN, Priority.ERROR, message, t);
       
  @@ -417,7 +405,7 @@
       @param message the message object to log */
     public
     void fatal(Object message) {
  -    if(disable >=  Priority.FATAL_INT) return;    
  +    if(hierarchy.disable >=  Priority.FATAL_INT) return;    
       if(Priority.FATAL.isGreaterOrEqual(this.getChainedPriority()))
         forcedLog(instanceFQN, Priority.FATAL, message, null);
     }
  @@ -433,7 +421,7 @@
      @param t the exception to log, including its stack trace.  */
     public
     void fatal(Object message, Throwable t) {
  -    if(disable >=  Priority.FATAL_INT) return;   
  +    if(hierarchy.disable >=  Priority.FATAL_INT) return;   
       if(Priority.FATAL.isGreaterOrEqual(this.getChainedPriority()))
         forcedLog(instanceFQN, Priority.FATAL, message, t);
     }
  @@ -512,19 +500,7 @@
     public
     static
     Enumeration getCurrentCategories() {
  -    // The accumlation in v is necessary because not all elements in
  -    // HierarchyMaintainer.ht are Category objects as there might be some
  -    // ProvisionNodes as well.       
  -    Vector v = new Vector(defaultHierarchy.ht.size());
  -    
  -    Enumeration elems = defaultHierarchy.ht.elements();
  -    while(elems.hasMoreElements()) {
  -      Object o = elems.nextElement();
  -      if(o instanceof Category) {
  -	v.addElement(o);
  -      }
  -    }
  -    return v.elements();
  +    return defaultHierarchy.getCurrentCategories();
     }
   
   
  @@ -667,9 +643,9 @@
       // This is one of the rare cases where we can use logging in order
       // to report errors from within log4j.
       if(rb == null) {
  -      if(!emittedNoResourceBundleWarning) {
  +      if(!hierarchy.emittedNoResourceBundleWarning) {
   	error("No resource bundle has been set for category "+name);
  -	emittedNoResourceBundleWarning = true;
  +	hierarchy.emittedNoResourceBundleWarning = true;
         }
         return null;
       }
  @@ -704,7 +680,7 @@
       @param message the message object to log */
     public
     void info(Object message) {
  -    if(disable >=  Priority.INFO_INT) return;    
  +    if(hierarchy.disable >=  Priority.INFO_INT) return;    
       if(Priority.INFO.isGreaterOrEqual(this.getChainedPriority()))
         forcedLog(instanceFQN, Priority.INFO, message, null);
     }
  @@ -720,7 +696,7 @@
      @param t the exception to log, including its stack trace.  */
     public
     void info(Object message, Throwable t) {
  -    if(disable >=  Priority.INFO_INT) return;   
  +    if(hierarchy.disable >=  Priority.INFO_INT) return;   
       if(Priority.INFO.isGreaterOrEqual(this.getChainedPriority()))
         forcedLog(instanceFQN, Priority.INFO, message, t);
     }
  @@ -762,7 +738,7 @@
      */
     public
     boolean isDebugEnabled() {
  -    if(disable >=  Priority.DEBUG_INT)
  +    if(hierarchy.disable >=  Priority.DEBUG_INT)
         return false;   
       return Priority.DEBUG.isGreaterOrEqual(this.getChainedPriority());
     }
  @@ -777,7 +753,7 @@
     */
     public
     boolean isEnabledFor(Priority priority) {
  -    if(disable >= priority.level) {
  +    if(hierarchy.disable >= priority.level) {
         return false;
       }
       return priority.isGreaterOrEqual(this.getChainedPriority());
  @@ -792,7 +768,7 @@
     */
     public
     boolean isInfoEnabled() {
  -    if(disable >= Priority.INFO_INT)
  +    if(hierarchy.disable >= Priority.INFO_INT)
         return false;   
       return Priority.INFO.isGreaterOrEqual(this.getChainedPriority());
     }
  @@ -808,7 +784,7 @@
        @since 0.8.4 */
     public
     void l7dlog(Priority priority, String key, Throwable t) {
  -    if(disable >= priority.level) {
  +    if(hierarchy.disable >= priority.level) {
         return;
       }
       if(priority.isGreaterOrEqual(this.getChainedPriority())) {
  @@ -832,7 +808,7 @@
     */
     public
     void l7dlog(Priority priority, String key,  Object[] params, Throwable t) {
  -    if(disable >= priority.level) {
  +    if(hierarchy.disable >= priority.level) {
         return;
       }    
       if(priority.isGreaterOrEqual(this.getChainedPriority())) {
  @@ -851,7 +827,7 @@
      */
     public
     void log(Priority priority, Object message, Throwable t) {
  -    if(disable >= priority.level) {
  +    if(hierarchy.disable >= priority.level) {
         return;
       }
       if(priority.isGreaterOrEqual(this.getChainedPriority())) 
  @@ -863,7 +839,7 @@
    */
     public
     void log(Priority priority, Object message) {
  -    if(disable >= priority.level) {
  +    if(hierarchy.disable >= priority.level) {
         return;
       }
       if(priority.isGreaterOrEqual(this.getChainedPriority()))
  @@ -882,7 +858,7 @@
     */
     public
     void log(String callerFQN, Priority priority, Object message, Throwable t) {
  -    if(disable >= priority.level) {
  +    if(hierarchy.disable >= priority.level) {
         return;
       }
       if(priority.isGreaterOrEqual(this.getChainedPriority())) {
  
  
  
  1.10      +179 -1    jakarta-log4j/org/apache/log4j/Hierarchy.java
  
  Index: Hierarchy.java
  ===================================================================
  RCS file: /home/cvs/jakarta-log4j/org/apache/log4j/Hierarchy.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- Hierarchy.java	2001/01/11 22:59:41	1.9
  +++ Hierarchy.java	2001/01/22 22:11:26	1.10
  @@ -18,11 +18,14 @@
   
   import java.util.Hashtable;
   import java.util.Enumeration;
  +import java.util.Vector;
   
   import org.apache.log4j.spi.RootCategory;
   import org.apache.log4j.spi.CategoryFactory;
   import org.apache.log4j.or.RendererMap;
   import org.apache.log4j.or.ObjectRenderer;
  +import org.apache.log4j.helpers.LogLog;
  +import org.apache.log4j.helpers.OptionConverter;
   
   /**
      This class is specialized in retreiving categories by name and
  @@ -49,15 +52,26 @@
   
   */
   public class Hierarchy {
  +
  +  // DISABLE_OFF should be set to a value lower than all possible
  +  // priorities.
  +  static final int DISABLE_OFF = -1;
  +  static final int DISABLE_OVERRIDE = -2;  
     
     static 
     private
     CategoryFactory defaultFactory = new DefaultCategoryFactory();
   
  +
     Hashtable ht;
     Category root;
  -  RendererMap rendererMap; 
  +  RendererMap rendererMap;
  +  
  +  int disable;
   
  +  boolean emittedNoAppenderWarning = false;
  +  boolean emittedNoResourceBundleWarning = false;  
  +
     /**
        Create a new Category hierarchy.
   
  @@ -68,6 +82,8 @@
     Hierarchy(Category root) {
       ht = new Hashtable();
       this.root = root;
  +    // Don't disable any priority level by default.
  +    disable = DISABLE_OFF;
       this.root.setHierarchy(this);
       rendererMap = new RendererMap();
     }
  @@ -113,6 +129,123 @@
       }
     }
   
  +  public
  +  void disable(String disableStr) {
  +    if(disable != DISABLE_OVERRIDE) {  
  +      Priority p = Priority.toPriority(disableStr, null);
  +      if(p != null) {
  +	disable = p.level;
  +      } else {
  +	LogLog.warn("Could not convert ["+disableStr+"] to Priority.");
  +      }
  +    }
  +  }
  +
  +
  +  /**
  +     Disable all logging requests of priority <em>equal to or
  +     below</em> the priority parameter <code>p</code>, regardless of
  +     the request category. Logging requests of higher priority then
  +     the priority of <code>p</code> remain unaffected.
  +
  +     <p>Nevertheless, if the {@link #DISABLE_OVERRIDE_KEY} system
  +     property is set to "true" or any value other than "false", then
  +     logging requests are evaluated as usual, i.e. according to the <a
  +     href="../../manual.html#selectionRule">Basic Selection Rule</a>.
  +
  +     <p>The "disable" family of methods are there for speed. They
  +     allow printing methods such as debug, info, etc. to return
  +     immediately after an interger comparison without walking the
  +     category hierarchy. In most modern computers an integer
  +     comparison is measured in nanoseconds where as a category walk is
  +     measured in units of microseconds.
  +
  +     <p>Other configurators define alternate ways of overriding the
  +     disable override flag. See {@link PropertyConfigurator} and
  +     {@link org.apache.log4j.xml.DOMConfigurator}.
  +
  +
  +     @since 0.8.5 */
  +  public
  +  void disable(Priority p) {
  +    if((disable != DISABLE_OVERRIDE) && (p != null)) {
  +      disable = p.level;
  +    }
  +  }
  +  
  +  /**
  +     Disable all logging requests regardless of category and priority.
  +     This method is equivalent to calling {@link #disable} with the
  +     argument {@link Priority#FATAL}, the highest possible priority.
  +
  +     @since 0.8.5 */
  +  public
  +  void disableAll() {
  +    disable(Priority.FATAL);
  +  }
  +
  +
  +  /**
  +     Disable all logging requests of priority DEBUG regardless of
  +     category.  Invoking this method is equivalent to calling {@link
  +     #disable} with the argument {@link Priority#DEBUG}.
  +
  +     @since 0.8.5 */
  +  public
  +  void disableDebug() {
  +    disable(Priority.DEBUG);
  +  }
  +
  +
  +  /**
  +     Disable all logging requests of priority INFO and below
  +     regardless of category. Note that DEBUG messages are also
  +     disabled.  
  +
  +     <p>Invoking this method is equivalent to calling {@link #disable}
  +     with the argument {@link Priority#INFO}.
  +
  +     @since 0.8.5 */
  +  public
  +  void disableInfo() {
  +    disable(Priority.INFO);
  +  }  
  +
  +  /**
  +     Undoes the effect of calling any of {@link #disable}, {@link
  +     #disableAll}, {@link #disableDebug} and {@link #disableInfo}
  +     methods. More precisely, invoking this method sets the Category
  +     class internal variable called <code>disable</code> to its
  +     default "off" value.
  +
  +     @since 0.8.5 */
  +  public
  +  void enableAll() {
  +    disable = DISABLE_OFF;
  +  }
  +  
  +  /**
  +     Override the shipped code flag if the <code>override</code>
  +     parameter is not null.
  +
  +     <p>If <code>override</code> is null then there is nothing to do.
  +     Otherwise, set Category.shippedCode to false if override has a
  +     value other than "false".     
  +  */
  +  public
  +  void overrideAsNeeded(String override) {
  +    // If override is defined, any value other than false will be
  +    // interpreted as true.    
  +    if(override != null) {
  +      LogLog.debug("Handling non-null disable override directive: \""+
  +		   override +"\".");
  +      if(OptionConverter.toBoolean(override, true)) {
  +	LogLog.debug("Overriding all disable methods.");
  +	disable = DISABLE_OVERRIDE;
  +      }
  +    }
  +  }
  +
   
     /**
        Return a new category instance named as the first parameter using
  @@ -178,6 +311,36 @@
       }
     }
   
  +
  +  /**
  +     Returns all the currently defined categories in this hierarchy as
  +     an {@link java.util.Enumeration Enumeration}.
  +
  +     <p>The root category is <em>not</em> included in the returned
  +     {@link Enumeration}.  */
  +  public
  +  Enumeration getCurrentCategories() {
  +    // The accumlation in v is necessary because not all elements in
  +    // ht are Category objects as there might be some ProvisionNodes
  +    // as well.
  +    Vector v = new Vector(ht.size());
  +    
  +    Enumeration elems = ht.elements();
  +    while(elems.hasMoreElements()) {
  +      Object o = elems.nextElement();
  +      if(o instanceof Category) {
  +	v.addElement(o);
  +      }
  +    }
  +    return v.elements();
  +  }
  +
  +
  +  public
  +  boolean isDisabled(int level) {
  +    return disable >=  level;
  +  }
  +
     /**
        Get the renderer map for this hierarchy.
     */
  @@ -313,6 +476,21 @@
         c.parent = cat;      
       }
     }    
  +
  +  /**
  +     Set the disable override value given a string.
  + 
  +     @since 1.1
  +   */
  +  public
  +  void setDisableOverride(String override) {
  +    if(OptionConverter.toBoolean(override, true)) {
  +      LogLog.debug("Overriding disable.");
  +      disable =  DISABLE_OVERRIDE;
  +    }
  +  }
  +
  +
   
     /**
        Shutting down a hiearchy will <em>safely</em> close and remove
  
  
  
  1.11      +6 -6      jakarta-log4j/org/apache/log4j/PropertyConfigurator.java
  
  Index: PropertyConfigurator.java
  ===================================================================
  RCS file: /home/cvs/jakarta-log4j/org/apache/log4j/PropertyConfigurator.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- PropertyConfigurator.java	2001/01/20 16:02:18	1.10
  +++ PropertyConfigurator.java	2001/01/22 22:11:27	1.11
  @@ -120,10 +120,10 @@
       For each named appender you can configure its {@link Layout}. The
       syntax for configuring an appender's layout is:
       <pre>
  -    log.appender.appenderName.layout=fully.qualified.name.of.layout.class
  -    log.appender.appenderName.layout.option1=value1
  +    log4j.appender.appenderName.layout=fully.qualified.name.of.layout.class
  +    log4j.appender.appenderName.layout.option1=value1
       ....
  -    log.appender.appenderName.layout.optionN=valueN
  +    log4j.appender.appenderName.layout.optionN=valueN
       </pre>
       
       <h3>Configuring categories</h3>
  @@ -190,7 +190,7 @@
       <p>The syntax is:
   
       <pre>
  -    log4j.renreder.fully.qualified.name.of.rendered.class=fully.qualified.name.of.rendering.class
  +    log4j.renderer.fully.qualified.name.of.rendered.class=fully.qualified.name.of.rendering.class
       </pre>
   
       As in,
  @@ -382,12 +382,12 @@
       // Check if the config file overides the shipped code flag.
       String override = properties.getProperty(
                                       BasicConfigurator.DISABLE_OVERRIDE_KEY);
  -    BasicConfigurator.overrideAsNeeded(override);
  +    hierarchy.overrideAsNeeded(override);
   
       if(override == null) {
         String disableStr = properties.getProperty(BasicConfigurator.DISABLE_KEY);
         if(disableStr != null)
  -	BasicConfigurator.disableAsNeeded(disableStr);      
  +	hierarchy.disable(disableStr);      
       }
       
       
  
  
  
  1.3       +1 -1      jakarta-log4j/org/apache/log4j/performance/NotLogging.java
  
  Index: NotLogging.java
  ===================================================================
  RCS file: /home/cvs/jakarta-log4j/org/apache/log4j/performance/NotLogging.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- NotLogging.java	2000/12/14 21:08:08	1.2
  +++ NotLogging.java	2001/01/22 22:11:31	1.3
  @@ -128,7 +128,7 @@
         ;       
       else if ("true".equals(args[0])) {
         System.out.println("Flagging as shipped code.");
  -      BasicConfigurator.disableInfo();
  +      Category.getDefaultHierarchy().disableInfo();
       }
       else 
         Usage();
  
  
  
  1.3       +1 -1      jakarta-log4j/org/apache/log4j/test/ShippedCodeFlagTest.java
  
  Index: ShippedCodeFlagTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-log4j/org/apache/log4j/test/ShippedCodeFlagTest.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ShippedCodeFlagTest.java	2000/12/14 21:08:13	1.2
  +++ ShippedCodeFlagTest.java	2001/01/22 22:11:33	1.3
  @@ -33,7 +33,7 @@
       else { 
         PropertyConfigurator.configure(type);
       }
  -    BasicConfigurator.disableInfo();       
  +    Category.getDefaultHierarchy().disableInfo();       
       CAT.debug("Hello world");
     }
   
  
  
  
  1.4       +5 -4      jakarta-log4j/org/apache/log4j/test/UnitTestCategory.java
  
  Index: UnitTestCategory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-log4j/org/apache/log4j/test/UnitTestCategory.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- UnitTestCategory.java	2000/12/21 16:22:05	1.3
  +++ UnitTestCategory.java	2001/01/22 22:11:33	1.4
  @@ -211,7 +211,8 @@
       Category root = Category.getRoot();    
       root.addAppender(caRoot);
   
  -    BasicConfigurator.disableDebug();
  +    Hierarchy h = Category.getDefaultHierarchy();
  +    h.disableDebug();
       assertEquals(caRoot.counter, 0);     
   
       root.debug(MSG); assertEquals(caRoot.counter, 0);  
  @@ -219,14 +220,14 @@
       root.log(Priority.WARN, MSG); assertEquals(caRoot.counter, 2);  
       root.warn(MSG); assertEquals(caRoot.counter, 3);  
   
  -    BasicConfigurator.disableInfo();
  +    h.disableInfo();
       root.debug(MSG); assertEquals(caRoot.counter, 3);  
       root.info(MSG); assertEquals(caRoot.counter, 3);  
       root.log(Priority.WARN, MSG); assertEquals(caRoot.counter, 4);  
       root.error(MSG); assertEquals(caRoot.counter, 5);  
       root.log(Priority.ERROR, MSG); assertEquals(caRoot.counter, 6);  
   
  -    BasicConfigurator.disableAll();
  +    h.disableAll();
       root.debug(MSG); assertEquals(caRoot.counter, 6);  
       root.info(MSG); assertEquals(caRoot.counter, 6);  
       root.log(Priority.WARN, MSG); assertEquals(caRoot.counter, 6);  
  @@ -234,7 +235,7 @@
       root.log(Priority.FATAL, MSG); assertEquals(caRoot.counter, 6);  
       root.log(Priority.FATAL, MSG); assertEquals(caRoot.counter, 6);  
   
  -    BasicConfigurator.disable(Priority.FATAL);
  +    h.disable(Priority.FATAL);
       root.debug(MSG); assertEquals(caRoot.counter, 6);  
       root.info(MSG); assertEquals(caRoot.counter, 6);  
       root.log(Priority.WARN, MSG); assertEquals(caRoot.counter, 6);  
  
  
  
  1.11      +15 -8     jakarta-log4j/org/apache/log4j/xml/DOMConfigurator.java
  
  Index: DOMConfigurator.java
  ===================================================================
  RCS file: /home/cvs/jakarta-log4j/org/apache/log4j/xml/DOMConfigurator.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- DOMConfigurator.java	2001/01/20 16:02:22	1.10
  +++ DOMConfigurator.java	2001/01/22 22:11:37	1.11
  @@ -71,7 +71,8 @@
     static final String ERROR_HANDLER_TAG	= "errorHandler";
     static final String REF_ATTR		= "ref";
     static final String ADDITIVITY_ATTR    = "additivity";  
  -  static final String SCFO_ATTR          = "disableOverride";
  +  static final String DISABLE_OVERRIDE_ATTR = "disableOverride";
  +  static final String DISABLE_ATTR       = "disable";
     static final String CONFIG_DEBUG_ATTR  = "configDebug";
     static final String RENDERING_CLASS_ATTR = "renderingClass";
     static final String RENDERED_CLASS_ATTR = "renderedClass";
  @@ -614,18 +615,24 @@
       else 
         LogLog.debug("Ignoring " + CONFIG_DEBUG_ATTR + " attribute.");
         
  -    String override = subst(element.getAttribute(SCFO_ATTR));
  +    String override = subst(element.getAttribute(DISABLE_OVERRIDE_ATTR));
       LogLog.debug("Disable override=\"" + override +"\".");
       // if the log4j.dtd is not specified in the XML file, then the
  -    // SCFO_ATTR attribute is returned as the empty string when it
  -    // is not specified in the XML file.
  +    // DISABLE_OVERRIDE attribute is returned as the empty string when
  +    // it is not specified in the XML file.
       if(!override.equals("") && !override.equals("null")) {
  -      // overrideAsNeeded is defined in BasicConfigurator.
  -      overrideAsNeeded(override);
  +      hierarchy.overrideAsNeeded(override);
       }
  -    else 
  -      LogLog.debug("Ignoring " + SCFO_ATTR + " attribute.");
  +
  +    String disableStr = subst(element.getAttribute(DISABLE_ATTR));
  +    LogLog.debug("Disable =\"" + disableStr +"\".");
  +    if(!"".equals(disableStr) && !"null".equals(disableStr)) {
  +      hierarchy.disable(disableStr);
  +    }
       
  +
  +
  +
       //Hashtable appenderBag = new Hashtable(11);
   
       /* Building Appender objects, placing them in a local namespace
  
  
  
  1.4       +6 -1      jakarta-log4j/org/apache/log4j/xml/log4j.dtd
  
  Index: log4j.dtd
  ===================================================================
  RCS file: /home/cvs/jakarta-log4j/org/apache/log4j/xml/log4j.dtd,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- log4j.dtd	2001/01/17 14:26:58	1.3
  +++ log4j.dtd	2001/01/22 22:11:37	1.4
  @@ -8,7 +8,11 @@
   
   <!ELEMENT logj:configuration (renderer*, appender*,category*,root?)>
   
  -<!-- The disableOverride attribute allows the user to override any
  +<!-- The disable attribute takes a priority value such that all
  +     logging statements with a prioroty equal or below this value are
  +     disabled.
  +
  +     The disableOverride attribute allows the user to override any
        BasicConfigurator.disable invocations made from within the
        application.
        
  @@ -23,6 +27,7 @@
   -->
        
   <!ATTLIST log4j:configuration
  +  disable                  (debug|info|warn|error|fatal|null)  "null"
     disableOverride          (true|false|null)  "null"
     configDebug              (true|false|null)  "null"
   >
  
  
  
  1.6       +6 -4      jakarta-log4j/org/apache/log4j/xml/examples/XCategory.java
  
  Index: XCategory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-log4j/org/apache/log4j/xml/examples/XCategory.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- XCategory.java	2001/01/19 16:45:36	1.5
  +++ XCategory.java	2001/01/22 22:11:40	1.6
  @@ -105,7 +105,7 @@
     public
     void lethal(String message, Throwable t) { 
       // disable is a static variable defined in Category class
  -    if(disable >=  XPriority.LETHAL_INT) 
  +    if(hierarchy.isDisabled(XPriority.LETHAL_INT)) 
         return;
       if(XPriority.LETHAL.isGreaterOrEqual(this.getChainedPriority()))
         forcedLog(instanceFQN, XPriority.LETHAL, message, t);
  @@ -117,7 +117,7 @@
     public
     void lethal(String message) { 
       // disable is a static variable defined in Category class
  -    if(disable >=  XPriority.LETHAL_INT) 
  +    if(hierarchy.isDisabled(XPriority.LETHAL_INT)) 
         return;
       if(XPriority.LETHAL.isGreaterOrEqual(this.getChainedPriority()))
         forcedLog(instanceFQN, XPriority.LETHAL, message, null);
  @@ -147,7 +147,8 @@
     public
     void trace(String message, Throwable t) { 
       // disable is defined in Category
  -    if(disable <=  XPriority.TRACE_INT) return;   
  +    if(hierarchy.isDisabled(XPriority.TRACE_INT))
  +      return;   
       if(XPriority.TRACE.isGreaterOrEqual(this.getChainedPriority()))
         forcedLog(instanceFQN, XPriority.TRACE, message, t);
     }
  @@ -158,7 +159,8 @@
     public
     void trace(String message) { 
       // disable is defined in Category
  -    if(disable <=  XPriority.TRACE_INT) return;   
  +    if(hierarchy.isDisabled(XPriority.TRACE_INT))
  +      return;   
       if(XPriority.TRACE.isGreaterOrEqual(this.getChainedPriority()))
         callAppenders(new LoggingEvent(instanceFQCN, this, XPriority.TRACE, 
   				     message, null));
  
  
  
  1.4       +1 -1      jakarta-log4j/org/apache/log4j/xml/test/DisableOverrideTest.java
  
  Index: DisableOverrideTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-log4j/org/apache/log4j/xml/test/DisableOverrideTest.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DisableOverrideTest.java	2000/12/19 13:23:40	1.3
  +++ DisableOverrideTest.java	2001/01/22 22:11:42	1.4
  @@ -37,7 +37,7 @@
       // System.exit(1);           
       //}
       DOMConfigurator.configure(configFile);
  -    DOMConfigurator.disableInfo();       
  +    Category.getDefaultHierarchy().disableInfo();       
       CAT.debug("Hello world");
     }
   
  
  
  
  1.4       +1 -1      jakarta-log4j/org/apache/log4j/xml/test/Makefile
  
  Index: Makefile
  ===================================================================
  RCS file: /home/cvs/jakarta-log4j/org/apache/log4j/xml/test/Makefile,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Makefile	2001/01/19 16:45:42	1.3
  +++ Makefile	2001/01/22 22:11:42	1.4
  @@ -1,7 +1,7 @@
    
   PKG_DIR :=org/apache/log4j/xml/test
   DEPTH   :=../../../../..
  -JSOURCES:=DOMTest.java DisableOverrideTest.java \
  +JSOURCES:=DOMTest.java DisableOverrideTest.java DisableTest.java \
   	SubClassTest.java\
   
   SUBDIRS :=