log4j -- PropertyConfigurator for multiple instances

T

Tush

I want to use multiple instances of the log4j Logger (open source by
Apache). I need to attach different Properties objects to each of
these log4j Logger instances.
Attached below is the code snippet where I am creating the instances
of the log4j Logger, setting the properties and storing in a Hash.

////////////////////////////////////////////////

Set setProp = logProperties.keySet();
Iterator itrProp = setProp.iterator();
while (itrProp.hasNext()) {

String strPropKey = (itrProp.next()).toString();
Properties propPropValue =
(Properties)logProperties.get(strPropKey);

// Creating a Logger instance
org.apache.log4j.Logger logger =
org.apache.log4j.Logger.getLogger(strPropKey);
// Setting the Logger properties
PropertyConfigurator.configure(propPropValue);

// Add the Logger Instance to the LoggerHash for later reference
this.loggerHash.put(strPropKey, logger);

} // End of Iterator While Loop

///////////////////////////////////////////////////

The problem I am facing is that the last Properties object gets set
for all the instances of the loggers created.
Is there some way by which we can specify properties of which logger
instance needs to be set while using the PropertyConfigurator, or is
there some other way of setting the individual Properties of the
logger instances ???

Please HELP !!!
Cheers
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top