This would be troublesome if multiple extensions were in use within the
same JVM. I do provide an alternative (referred to as "very manual
configuration" in the package javadocs) that leaves the hierarchy alone.
Unfortunately, this does not occur automatically (as implied by the name
"very manual").
It's certainly something that needs to be worked out because I'm planning
to use multiple extensions in the near future. (Namely, ServletCategory
and EJB Category; which could conceivably be present in the same JVM).
Presently, PropertyConfigurator only supports configuration of one category
factory. As it is now, I don't see how multiple extensions could step on
each other without doing so manually.
- Paul
Paul Glezen
IT Specialist
Software Services
818 539 3321
Ceki Gülcü <[EMAIL PROTECTED]> on 06/04/2001 12:55:24 AM
Please respond to "LOG4J Developers Mailing List"
<[EMAIL PROTECTED]>
To: "LOG4J Developers Mailing List" <[EMAIL PROTECTED]>
cc:
Subject: 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: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
--
Ceki Gülcü
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]