You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by Dário Luís Coneglian Oliveros <ol...@cpqd.com.br> on 2005/04/07 15:44:42 UTC

configureAndWatch contribution

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 {@link 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: log4j-dev@logging.apache.org
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
oliveros@cpqd.com.br
www.cpqd.com.br


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org