3.6 Is there a way to get log4j to automatically reload a configuration
file if it changes?

Yes. Both the DOMConfigurator and the PropertyConfigurator support
automatic reloading through the configureAndWatch method. See the API
documentation for more details.

Because the configureAndWatch launches a separate wathdog thread, and
because there is no way to stop this thread in log4j 1.2, the
configureAndWatch method is unsafe for use in J2EE envrironments where
applications are recycled.

Also: the following code might help you.

URL configURL = new URL("file:"+configFile.getAbsolutePath());

// now watch the file for changes
      FileWatchdog watchdog = new FileWatchdog();
      watchdog.setURL(configURL);
      watchdog.setInterval(2000);
      watchdog.setConfigurator(PropertyConfigurator.class.getName());
 
LogManager.getLoggerRepository().getPluginRegistry().addPlugin(watchdog)
;
      watchdog.activateOptions();


Hope this helps,

-Kamal.

-----Original Message-----
From: news [mailto:[EMAIL PROTECTED] On Behalf Of Eric B.
Sent: Friday, May 11, 2007 3:12 PM
To: [email protected]
Subject: File Watchdogs

Hi,

I'm trying to use Log4j 1.3alpha-8 watchdog for my XML configuration
file,
but am having difficulties.

I've tried the following:

FileWatchdog confiFileWatchdog = new FileWatchdog();
configFileWatchdog.setFile( log4j.xml path );
configFileWatchdog.activateOptions();


But I get the following error message:
ERROR org.apache.log4j.watchdog.FileWatchdog - watchdog requires
repository
that supports LoggerRepositoryEx


I'm not entirely sure how to create my loggers such that the repository
supports LoggerRepositoryEx.  Is there something special I need to do in
the
log4j.xml file to accomplish this?  Are the watchdogs not yet supported?


If watchdogs are not yet fully supported, how can I programatically
reload 
my log4j.xml configuration file?

Thanks,

Eric






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