View Javadoc

1   /*
2    * Copyright 2007 the original author or authors.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package org.goetz.domino.log4j.config;
18  
19  import java.io.File;
20  
21  import org.apache.log4j.LogManager;
22  import org.apache.log4j.PropertyConfigurator;
23  import org.apache.log4j.helpers.LogLog;
24  
25  /***
26   * This class 
27   * 
28   * @author Bernd G?tz
29   *
30   * TODO To change the template for this generated type comment go to
31   * Window - Preferences - Java - Code Style - Code Templates
32   */
33  public class ConfigFileWatcher extends FileWatcher {
34  
35  	/***
36  	 * Constructor.
37  	 * 
38  	 * @param file file to check for changes.
39  	 */
40  	public ConfigFileWatcher(File file) {
41  		super(file);
42  	}
43  
44  	/* (non-Javadoc)
45  	 * @see org.goetz.domino.log4j.config.FileWatcher#onChange(java.io.File)
46  	 */
47  	protected void onChange(File f) {
48  		LogLog.debug("Resetting log4j configuration now...");
49  		LogManager.resetConfiguration();
50  		String name = f.getAbsolutePath();
51  		PropertyConfigurator.configure(name);
52  		LogLog.debug("Configuration successfully reloaded");
53  	}
54  
55  }