You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by Ceki Gülcü <cg...@qos.ch> on 2001/06/04 09:55:24 UTC

Recent commit by Paul

Hello Paul,

The recent addition of 

   Category.getDefaultHierarchy().setCategoryFactory(categoryFactory);

in configureCategoryFactory method in PropertyConfigurator.java is troublesome. Setting the category factory once and fall al may be suitable in certain cases but precludes different extensions of Category class to live side by side. This will come and bite us again and again.

This is it for now. Ceki

At 06:20 04.06.2001 +0000, you wrote:
>pglezen     01/06/03 23:20:57
>
>  Modified:    src/java/org/apache/log4j PropertyConfigurator.java
>                        Hierarchy.java
>  Log:
>  1. PropertyConfigurator - Added a few lines to
>        configureCategoryFactory to take advantage of the
>        PropertySetter class.
>  2. Hierarchy - Added a setter for the default category
>        factory so that Category.getInstance uses the
>        correct factory.  The default category was changed
>        to non-static.  This allows one to use different
>        factories for different hierarchies.
>  
>  Revision  Changes    Path
>  1.26      +7 -4      jakarta-log4j/src/java/org/apache/log4j/PropertyConfigurator.java
>  
>  Index: PropertyConfigurator.java
>  ===================================================================
>  RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/PropertyConfigurator.java,v
>  retrieving revision 1.25
>  retrieving revision 1.26
>  diff -u -r1.25 -r1.26
>  --- PropertyConfigurator.java 2001/05/31 16:55:19     1.25
>  +++ PropertyConfigurator.java 2001/06/04 06:20:56     1.26
>  @@ -87,11 +87,12 @@
>     protected Hashtable registry = new Hashtable(11);
>     protected CategoryFactory categoryFactory = new DefaultCategoryFactory();
>     
>  -  static final String CATEGORY_PREFIX = "log4j.category.";
>  -  static final String ADDITIVITY_PREFIX = "log4j.additivity.";
>  +  static final String      CATEGORY_PREFIX = "log4j.category.";
>  +  static final String       FACTORY_PREFIX = "log4j.factory";
>  +  static final String    ADDITIVITY_PREFIX = "log4j.additivity.";
>     static final String ROOT_CATEGORY_PREFIX = "log4j.rootCategory";
>  -  static final String APPENDER_PREFIX = "log4j.appender.";  
>  -  static final String RENDERER_PREFIX = "log4j.renderer.";
>  +  static final String      APPENDER_PREFIX = "log4j.appender.";  
>  +  static final String      RENDERER_PREFIX = "log4j.renderer.";
>   
>     /** Key for specifying the {@link org.apache.log4j.spi.CategoryFactory
>         CategoryFactory}.  Currently set to 
>  @@ -459,6 +460,8 @@
>                     OptionConverter.instantiateByClassName(factoryClassName,
>                                                        CategoryFactory.class, 
>                                                        categoryFactory);
>  +      PropertySetter.setProperties(categoryFactory, props, FACTORY_PREFIX + ".");
>  +      Category.getDefaultHierarchy().setCategoryFactory(categoryFactory);
>       }
>     }
>   
>  
>  
>  
>  1.16      +13 -3     jakarta-log4j/src/java/org/apache/log4j/Hierarchy.java
>  
>  Index: Hierarchy.java
>  ===================================================================
>  RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/Hierarchy.java,v
>  retrieving revision 1.15
>  retrieving revision 1.16
>  diff -u -r1.15 -r1.16
>  --- Hierarchy.java    2001/05/20 11:01:13     1.15
>  +++ Hierarchy.java    2001/06/04 06:20:56     1.16
>  @@ -61,9 +61,7 @@
>     static final int DISABLE_OFF = -1;
>     static final int DISABLE_OVERRIDE = -2;  
>     
>  -  static 
>  -  private
>  -  CategoryFactory defaultFactory = new DefaultCategoryFactory();
>  +  private CategoryFactory defaultFactory;
>   
>   
>     Hashtable ht;
>  @@ -89,6 +87,7 @@
>       disable = DISABLE_OFF;
>       this.root.setHierarchy(this);
>       rendererMap = new RendererMap();
>  +     defaultFactory = new DefaultCategoryFactory();
>     }
>   
>     /**
>  @@ -404,6 +403,17 @@
>         }
>       }
>       rendererMap.clear();
>  +  }
>  +
>  +  /**
>  +     Set the default CategoryFactory instance.
>  +
>  +     @since 1.1
>  +   */
>  +  public void setCategoryFactory(CategoryFactory factory)
>  +  {
>  +    if (factory != null)
>  +      defaultFactory = factory;
>     }
>   
>     /**
>  
>  
>  
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: log4j-cvs-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: log4j-cvs-help@jakarta.apache.org

--
Ceki Gülcü


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: log4j-dev-help@jakarta.apache.org