Obviously, it's functionality I'd be interested in using, since I asked
the original question. I think it would be helpful because you can just
set the log4j.configuration system property, and then start using
Categories throughout your code without having to worry about setting up a
Property or DOM configurator to be sure your config file is reloaded.
-Larry
On Thu, 16 Aug 2001, Mark Womack wrote:
> I got a chance to play with this today, and enclosed is a new file and some
> patches that implement this. GenericFileWatchdog.java should go in the
> org/apache/log4j/helpers directory.
>
> This is a rouch first pass, and I would appreciate feedback on this. Does
> anyone think this functionality would be useful or just give up now? These
> changes are only working in the DOMCOnfigurator right now, but if deemed
> useful, could easily be applied to PropertyConfigurator (I think).
>
> - Modified FileWatchdog.java to
> 1) support an empty constructor
> 2) support a filename setter and delay the setting of filename and file
> members.
> 3) support to exit the thread
> 4) support a static method, setFileWatchdog() which maintains a single
> FileWatchdog object. When called, stop the previous one and starts the new
> one.
>
> - Created GenericFileWatchdog.java as a subclass of FileWatchdog.java. This
> class allows you to define a configurator class, and calls the
> OptionConverter.selectAndConfigure() method to do the actual configuration.
>
> - Modified DOMConfigurator.java to:
> 1) Use GenericFileWatchdog instead of the local XMLWatchdog class.
> 2) use parseWatcher to create a Watchdog object from the xml input.
> 3) Call the FileWatchdog.setFileWatchdog() method to start the given
> watchdog.
>
> - Modified log4j.dtd to support a watcher element.
>
> Here's an example of a watcher element in the xml file:
>
> <watcher>
> <url value="file:/d:/development/my_properties/trace.xml"/>
> <delay value="10"/>
> </watcher>
>
> Some notes:
>
> 1) If I was going to submit this for real I would take some time to rework
> the FileWatchdog.java class to contain more of the stuff that might be
> common to all subclasses.
> 2) It is possible to get multiple FileWatchdogs watching files and updating
> the configuration. I don't know if this is a "feature" or "bug". This is
> why I added the FileWatchdog.setFileWatchdog() method, so that only one
> watchdog is running at a time. Also, I had to take some care to set the
> lastModif member so that I did not get into an infinite loop of creating a
> watchdog and reconfiguring. But I think more time needs to be spent
> discussing this and implementing it better.
>
> Please review and comment. I think this is a neat feature and would like to
> work to get it into log4j if there is sufficient interest.
>
> -Mark
>
> -----Original Message-----
> From: Mark Womack
> Sent: Wednesday, August 15, 2001 11:12 AM
> To: 'LOG4J Users Mailing List'
> Subject: RE: Specifying config file reload interval in config file
> itself?
>
>
> I looked at the code and thought about this a little more.
>
> The PropertyConfigurator and the DOMConfigurator have their own subclasses
> of FileWatchdog which define the doOnChange method to instantiate that
> particular configurator class and configure. But, what if we created a new
> FileWatchdog subclass called GenericFileWatchdog (or some such) that:
>
> 1) In addition to the filename and delay, you could optionally specify the
> configurator class to use.
> 2) If no configurator class is specified, then it falls back to the same
> logic used when initializing log4j from the log4j.configuration property (if
> the filename ends in .xml, use the DOMConfigurator, etc).
>
> Then, we could modify the Property and DOM configurator to handle new
> settings for the watchdog. In the DOM case, something like this:
>
> <watchdog>
> <url name="your_url_here"/>
> <delay value="20"/> <!-- in milliseconds -->
> <configurator classname="org.apache.log4j.xml.DOMConfigurator"/>
> </watchdog>
>
> In the DOM case, we can add a parseWatchdog method that does the right
> thing.
>
> Also, some care might need to be taken in the GenericFileWatchdog to not use
> the FileWatchdog constructor since it calls checkAndConfigure(). Since we
> are in the middle of configuration when reading the property or dom file, I
> don't think we want to have it restart the configuration...
>
> What do folks think?
>
> -Mark
>
> -----Original Message-----
> From: Mark Womack
> Sent: Wednesday, August 15, 2001 10:49 AM
> To: 'LOG4J Users Mailing List'
> Subject: RE: Specifying config file reload interval in config file
> itself?
>
>
> Larry, the DOMConfigurator lets you call configureAndWatch() as well. I was
> looking through the dtd, and to me there is no obvious way to specify a
> reload interval. Maybe someone more knowledgeable will speak up.
>
> I really like this idea though. If the functionality is not there, I think
> it should be added. Seems to me that you just need to specify settings for
> a FileWatchdog object. Of course, code would need to be added to handle the
> property settings and create/make the appropriate calls.
>
> -Mark
>
> -----Original Message-----
[...]
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]