Hi Paul,

I also want to extend Category in the way AppServerCategory does. After reading the posts of Josh's and yours, I still have
questions about using configurator.
In the article "http://jakarta.apache.org/log4j/docs/deepExtension.html", there is the following lines about configurator:
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------

....any

AppServerCategory that one might want to be configured through a configurator should be instantiated before the configure method is invoked........
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------


I didn't read the code of PropertyConfigurator.java and DomConfigurator.java, so I don't know why the created instances are not of
AppServerCategory. The following lines is from your post:
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
AppServerCategoryFactory factory =
new AppServerCategoryFactory("My Server", null, null);
AppServerCategory.setFactory( factory );

// Run some configurator here.

// Then later in code where you need a reference to a
// category.

Category myCat = AppServerCategory.getInstance("my.cat");
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
It appears you instantiate "myCat" after the configure method invoked. I am a little confused here.
Then what is the "right" way to use configurator on AppServerCategory ?
Is it possible(or senseful) to extend DomConfigurator.java or PropertyConfigurator.java for AppServerCategory ?

Thanks

Jin




Hi Josh,

By setting the hostname, server name, etc on the AppServerCategoryFactory,
you automatically have them set on the Category instances created by the
factory. The getter/setter methods on the AppServerCategory class are only
there for special override purposes. I've never used them myself. In
fact, in my code, all references to AppServerCategory instances are of type
Category. So my initialization code looks something like this at program
start-up:

AppServerCategoryFactory factory =
new AppServerCategoryFactory("My Server", null, null);
AppServerCategory.setFactory( factory );

// Run some configurator here.

// Then later in code where you need a reference to a
// category.

Category myCat = AppServerCategory.getInstance("my.cat");

The instance of myCat will automatically be populated with the hostname and
server name set on the AppServerCategoryFactory.

There is more information about this in a "get-acquainted" doc at

jakarta.apache.org/log4j/deepExtension.html

If any of it is unclear, then let me know so that I can change it. I
appreciate your feedback.

Cheers,
- Paul

--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to