1
2
3
4
5
6
7
8
9
10
11
12
13
14
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
45
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 }