Hi all,

I would like to make a contribution to DOMConfiguration class by overloading 
the configureAndWatch method so it can accept a LoggerRepository as an 
argument. This is very useful when you have EARs with different log4j 
configuration files and want to configure them dynamically.

DOMConfigurator.java:
...
    /**
     * ....
     * @param repository
     *            A logger repository.
     */
    static public void configureAndWatch(String configFilename, long delay,
            LoggerRepository repository) {
        XMLWatchdog xdog = new XMLWatchdog(configFilename, repository);
        xdog.setDelay(delay);
        xdog.start();
    }
...
class XMLWatchdog extends FileWatchdog {
  private LoggerRepository repository = null;

  XMLWatchdog(String filename) {
    super(filename);
  }

  XMLWatchdog(String filename, LoggerRepository repository) {
      super(filename);
      this.repository = repository;
  }

  /**
     Call [EMAIL PROTECTED] PropertyConfigurator#configure(String)} with the
     <code>filename</code> to reconfigure log4j. */
  public
  void doOnChange() {
    if (repository == null) {
       new DOMConfigurator().doConfigure(filename, 
                                      LogManager.getLoggerRepository());
    } else {
         new DOMConfigurator().doConfigure(filename, repository);
    }
  }
}

Please let me know your comments.

Thanks,
Dario Oliveros


-----Original Message-----
From: D�rio Lu�s Coneglian Oliveros 
Sent: quarta-feira, 23 de mar�o de 2005 18:05
To: [email protected]
Subject: Contribution to DOMConfigurator


Hi there,

I would like to make a contribution to log4j, but I am not sure how to proceed.
Basically I would like to overload the configureAndWatch method from 
DOMConfigurator to accept a new argument: LoggerRepository.
This issue came up when I decided to have two different configuration files for 
two different scoped EARs, which one of them having its own repository. At 
first I could get it working, but I was not able to configure their respective 
config files dynamically through use of DOMConfigurator.configureAndWatch(). 
That�s because the watchdog thread started by this method always invokes 
LogManager.getLoggerRepository.
Please let me know any comments or concerns you may have.

Thanks in advance.

D�rio Lu�s C. Oliveros
Software Architect
CPqD Telecom & IT Solutions
Tel.: +55 19 3705-4586 / Fax: +55 19 3705-6135
[EMAIL PROTECTED]
www.cpqd.com.br


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