It's quite relevant.  When the class attribute is specified for a Category,
that class's getInstance method is used to instanciate it.  Often the
category class will initialize and stash a default instance of the required
factory.  But if one wants to configure attributes on a factory, the
factory configuration should occur before the category configuration.

This ordering is strictly controlled in PropertyConfigurator.  But
DOMConfigurator iterates through the root element's children and configures
categories, renderers and category roots in whatever order the iterator
returns them.  If factories are thrown in the mix, I don't know that there
is a gaurantee the factories will be configured first; even if they appear
first in the XML file.

As I mentioned below, it should be sufficient to make a first pass through
the root element children configuring only factories.   Leave alone the
loop that is already there for the categories, roots and renderers.

- Paul

Paul Glezen
IT Specialist
Software Services
818 539 3321


Ceki Gülcü <[EMAIL PROTECTED]> on 06/20/2001 01:53:15 PM

Please respond to "LOG4J Developers Mailing List"
      <[EMAIL PROTECTED]>

To:   "LOG4J Developers Mailing List" <[EMAIL PROTECTED]>
cc:
Subject:  Re: Configure Category Factory for DOMConfigurator



Hello,

I am not sure if this entirely relevant but just to double check. You are
aware that for a given category you can specify its class.  For example:


<log4j:configuration xmlns:log4j='http://jakarta.apache.org/log4j/'>
        <appender name="STDOUT" class="org.apache.log4j.ConsoleAppender">
           <layout class="org.apache.log4j.PatternLayout">
             <param name="ConversionPattern"
                    value="%t - %m\n"/>
           </layout>
        </appender>

        <!-- Note the class attribute! -->
        <category name="foo.bar"
                  class="org.apache.log4j.xml.examples.XCategory">
          <priority value="info" />
        </category>

        <root>
           <priority value ="trace"
                     class="org.apache.log4j.xml.examples.XPriority"/>
           <appender-ref ref="STDOUT" />
        </root>

</log4j:configuration>

The "foo.bar" class will be instantiated as a
"org.apache.log4j.xml.examples.XCategory".

Regards, Ceki

At 13:33 20.06.2001 -0700, you wrote:
>Umair,
>
>Thanks to your timely prompting I checked out what would be required to
>enable DOMConfigurator to parse CategoryFactory entries in an XML file.
>The following changes to DOMConfigurator should do it.
>
>  - add a parseCategoryFactory(Element) method that
>    would handle the creation of the factory and its
>    configuration.
>  - invoke parseCategoryFactory from parse(Element, Hierarchy)
>  - add a string constant for the category factory tag
>
>Also the log4j.dtd should be modified to reflect the new tag.
>
>Presently the DOMConfigurator iterates over the child elements of the root
>element checking for Category tags, root category tags and renderer tags.
>It seems reasonable to add category factory tags to this list.  The only
>unexpected behavior I know of to arise from this is if someone places a
>category definition before a category factory definition (or if the child
>element iterator encounters a category before it's corresponding factory).
>Then parseCategory would use an unconfigured factory to create the
>category.  A way to prevent this problem would be to make a separate walk
>through the children of the root and check for factory tags.  Then do it
>again for categories, roots and renderers as it is now.
>
>If this sounds ok, I can implement it on Friday.  Tonight doesn't look
good
>and Thursday night I'll be travelling.
>
>- Paul
>
>Paul Glezen
>IT Specialist
>Software Services
>818 539 3321
>
>
>Umair Akeel <[EMAIL PROTECTED]> on 06/19/2001 02:57:09 PM
>
>Please respond to "LOG4J Developers Mailing List"
>      <[EMAIL PROTECTED]>
>
>To:   "'[EMAIL PROTECTED]'" <[EMAIL PROTECTED]>
>cc:
>Subject:  Configure Category Factory for DOMConfigurator
>
>
>
>I am working with Log4J and have extended the Category
>class and to be able to use the DOMConfigurator class
>I need to set the correct CategoryFactory.
>
>Its current behaviour is to use the default category factory
>from the Hierarchy. PropertyConfigurator on the other hand
>has the ability to setup a FactoryClass. Doing this is not
>at all difficult and I was wondering who should be contacted
>to make this enhancement into the tree ?
>
>Thanks a lot
>
>
>Umair Akeel
>Trigo, Inc.
>8000 Marina Blvd.,  Suite 810
>Brisbane, CA 94005
>Tel: (650) 827-0500 x124
>Fax: (650) 827-0501
>[EMAIL PROTECTED]
>
>
>---------------------------------------------------------------------
>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]

--
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]

Reply via email to