/*
 Copyright (C) 2005 mkraegeloh@sulis.de

purpose: little wrapper allowing to make log4j reread it's configuration if properties are modified.

This program is free software; you can redistribute it and/or modify it under the terms of the
GNU Lesser General Public License as published by the Free Software Foundation;
see http://www.gnu.org/licenses/lgpl.html (und deutsch: http://www.gnu.de/lgpl-ger.html)

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU Lesser General Public License for more details.

*/

package ext.tools;
import org.apache.log4j.*;
import org.apache.log4j.spi.*;
import java.net.*;
/**
  *  make log4j reread it's configuration if properties are modified;
  *  to force usage of this class start java with -Dlog4j.configuratorClass=ext.tools.PropertyConfigurator<br>
  *  to change the watch interval from 1 minute default (60000 millis) to say 5 minutes use -DwatchInterval=300000
  *
  * @author mkraegeloh
  * @version 1.0
  */

public class  PropertyConfigurator extends org.apache.log4j.PropertyConfigurator{
   public static final String CVSVersion = "$Header: /usr/local/cvsroot/SULIS/src/ext/tools/PropertyConfigurator.java,v 1.3 2007/01/22 10:41:43 mkr Exp $";
/**
  * overridden to call configureAndWatch
  *
  * @param configURL	
  * @param hierarchy	
  * @return void	
*/
public void doConfigure(URL configURL, LoggerRepository hierarchy) {
   String l=System.getProperty("watchInterval","60000");
   long li=Long.parseLong(l);
   System.out.println("intercepted log config for "+configURL.getFile()+" to configureAndWatch interval="+li+" millis");
   configureAndWatch(configURL.getFile(),li);
}
}
