1.1 restoration
[mir.git] / source / mir / log / log4j / LoggerImpl.java
index 99ebed4..cd80fd8 100755 (executable)
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
  * In addition, as a special exception, The Mir-coders gives permission to link
- * the code of this program with  any library licensed under the Apache Software License, 
- * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library 
- * (or with modified versions of the above that use the same license as the above), 
- * and distribute linked combinations including the two.  You must obey the 
- * GNU General Public License in all respects for all of the code used other than 
- * the above mentioned libraries.  If you modify this file, you may extend this 
- * exception to your version of the file, but you are not obligated to do so.  
+ * the code of this program with  any library licensed under the Apache Software License,
+ * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library
+ * (or with modified versions of the above that use the same license as the above),
+ * and distribute linked combinations including the two.  You must obey the
+ * GNU General Public License in all respects for all of the code used other than
+ * the above mentioned libraries.  If you modify this file, you may extend this
+ * exception to your version of the file, but you are not obligated to do so.
  * If you do not wish to do so, delete this exception statement from your version.
  */
 package mir.log.log4j;
@@ -33,8 +33,8 @@ import java.util.HashMap;
 import java.util.Map;
 
 import mir.config.MirPropertiesConfiguration;
-import mir.config.MirPropertiesConfiguration.PropertiesConfigExc;
-
+import mir.log.LoggerExc;
+import mir.log.LoggerFailure;
 import org.apache.log4j.Logger;
 import org.apache.log4j.PropertyConfigurator;
 
@@ -42,33 +42,53 @@ import org.apache.log4j.PropertyConfigurator;
 public class LoggerImpl implements mir.log.Logger {
   private static Map loggers = new HashMap();
 
-  public LoggerImpl() throws PropertiesConfigExc {
-    System.setProperty("log.home",
-        MirPropertiesConfiguration.instance().getStringWithHome("Log.Home"));
-    PropertyConfigurator.configure(
-        MirPropertiesConfiguration.instance().getStringWithHome("Log.log4j.ConfigurationFile").trim());
+  public LoggerImpl() throws LoggerExc {
+    reload();
   }
 
+  /** {@inheritDoc} */
   public void debug(Object o, String s) {
     this.getLogger(o).debug(s);
   }
 
+  /** {@inheritDoc} */
   public void info(Object o, String s) {
     this.getLogger(o).info(s);
   }
 
+  /** {@inheritDoc} */
   public void warn(Object o, String s) {
     this.getLogger(o).warn(s);
   }
 
+  /** {@inheritDoc} */
   public void error(Object o, String s) {
     this.getLogger(o).error(s);
   }
 
+  /** {@inheritDoc} */
   public void fatal(Object o, String s) {
     this.getLogger(o).fatal(s);
   }
 
+  /** {@inheritDoc} */
+  public void reload() throws LoggerExc, LoggerFailure {
+    try {
+      synchronized (loggers) {
+        System.setProperty("log.home",
+            MirPropertiesConfiguration.instance().getFile("Log.Home").getAbsolutePath());
+
+        PropertyConfigurator.configure(
+            MirPropertiesConfiguration.instance().getFile("Log.log4j.ConfigurationFile").getAbsolutePath());
+
+        loggers.clear();
+      }
+    }
+    catch (Throwable t) {
+      throw new LoggerFailure(t);
+    }
+  }
+
   private Logger getLogger(Object o) {
     String name;
     Logger l;