log4j -- PropertyConfigurator for multiple instances

Discussion in 'Java' started by Tush, Sep 29, 2004.

  1. Tush

    Tush Guest

    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
     
    Tush, Sep 29, 2004
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Alexandra Stehman

    eclipse, junit, log4j, & finding log4j.xml

    Alexandra Stehman, Jan 19, 2004, in forum: Java
    Replies:
    0
    Views:
    5,854
    Alexandra Stehman
    Jan 19, 2004
  2. Alex Hunsley
    Replies:
    2
    Views:
    13,079
    =?ISO-8859-15?Q?Fr=E9d=E9ric_G=E9din?=
    May 28, 2004
  3. Rodolfo
    Replies:
    0
    Views:
    984
    Rodolfo
    Jul 12, 2004
  4. joes
    Replies:
    1
    Views:
    2,283
  5. Gianni Galore
    Replies:
    0
    Views:
    1,316
    Gianni Galore
    Sep 8, 2010
Loading...

Share This Page