Rather than hacking Log4J's source, here's how I accomplished it :

1.  Create a custom LoggerConfigurator, "MyConfigurator", extending
PropertyConfigurator
2.  Set the properties file to use this configurator.

...
public class MyLoggerConfigurator extends PropertyConfigurator {

        private static final int POLLING_DELAY = 5000;

    /**
     * overrides the PropertyConfigurator's implementation of 
     * the Configurator interface's doConfigure(URL, LoggerRepository)
     * method.
     * 
     * Be advised that this method takes the URL and grabs the file off 
     * the end... meaning it really only works with file URLs.  This is 
     * because of the definition of the Configurator interface, and was 
     * the only way to make this work without hacking the Log4J source 
     * (LogManager's static initializer and some other stuff?).
     * 
     * The Configurator interface and configureAndWatch FileWatchdog
     * facilities will be cleaner in future versions of Log4J, according
to 
     * recent traffic on [EMAIL PROTECTED], though. 
     */

        public void doConfigure(URL url, LoggerRepository repository) {
                configureAndWatch(url.getFile(), POLLING_DELAY);
        }
}
...

Regards,


Scott 

-----Original Message-----
From: Bomb Diggy [mailto:[EMAIL PROTECTED]] 
Sent: Wednesday, June 12, 2002 4:09 PM
To: [EMAIL PROTECTED]
Subject: Re: Re-read configuration file via configureAndWatch()

There was a post a couple of months ago about being
able to 'set' configureAndWatch() via the
log4j.properties file.

http://www.mail-archive.com/log4j-user@jakarta.apache.org/msg04352.html

Is this feature planned for future releases of Log4J?

I hacked on the source a little and managed to get it
working.  Totally cool, but my hack is just that. 
Log4J now automatically finds my log4j.properties file
(in the Tomcat classpath) and tells itself to reload
every 60 seconds.

The code snippet is at:
http://www.acromedia.com/PCUpdate.html



__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com

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


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

Reply via email to