[logback-dev] svn commit: r1528 - in logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic: jmx selector util

noreply.ceki at qos.ch noreply.ceki at qos.ch
Mon May 7 18:22:02 CEST 2007


Author: ceki
Date: Mon May  7 18:22:02 2007
New Revision: 1528

Modified:
   logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/jmx/Configurator.java
   logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/selector/ContextJNDISelector.java
   logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/util/ContextInitializer.java

Log:

The autoConfig method in ContextInitializer class now throws a JoranException 


Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/jmx/Configurator.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/jmx/Configurator.java	(original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/jmx/Configurator.java	Mon May  7 18:22:02 2007
@@ -48,8 +48,12 @@
     LoggerContext lc = (LoggerContext) context;
     addInfo("Shutting down context: " + lc.getName());
     lc.shutdownAndReset();
-    ContextInitializer.autoConfig(lc, lc.getClass().getClassLoader());
-    addInfo("Context: " + lc.getName() + " reloaded.");
+    try {
+      ContextInitializer.autoConfig(lc, lc.getClass().getClassLoader());
+      addInfo("Context: " + lc.getName() + " reloaded.");
+    } catch(JoranException je) {
+      addError("Reloading of context: " + lc.getName() + " failed.", je);
+    }
   }
 
   public void reload(String fileName) throws JoranException {

Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/selector/ContextJNDISelector.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/selector/ContextJNDISelector.java	(original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/selector/ContextJNDISelector.java	Mon May  7 18:22:02 2007
@@ -94,7 +94,11 @@
         if (configFilePath != null) {
           configureLoggerContextByResource(loggerContext, configFilePath);
         } else {
-          ContextInitializer.autoConfig(loggerContext);
+          try {
+            ContextInitializer.autoConfig(loggerContext);
+          } catch(JoranException je) {
+            StatusPrinter.print(loggerContext);
+          }
         }
       }
       return loggerContext;

Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/util/ContextInitializer.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/util/ContextInitializer.java	(original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/util/ContextInitializer.java	Mon May  7 18:22:02 2007
@@ -7,7 +7,6 @@
 import ch.qos.logback.classic.joran.JoranConfigurator;
 import ch.qos.logback.core.joran.spi.JoranException;
 import ch.qos.logback.core.util.Loader;
-import ch.qos.logback.core.util.StatusPrinter;
 
 public class ContextInitializer {
 
@@ -24,26 +23,24 @@
     configurator.doConfigure(url);
   }
 
-  public static void autoConfig(LoggerContext loggerContext, ClassLoader classLoader) {
+  public static void autoConfig(LoggerContext loggerContext,
+      ClassLoader classLoader) throws JoranException {
     URL url = Loader.getResource(TEST_AUTOCONFIG_FILE, classLoader);
     if (url == null) {
       url = Loader.getResource(AUTOCONFIG_FILE, classLoader);
     }
 
     if (url != null) {
-      try {
-        configureByResource(loggerContext, url);
-      } catch (JoranException je) {
-        StatusPrinter.print(loggerContext);
-      }
+      configureByResource(loggerContext, url);
     } else {
-        BasicConfigurator.configure(loggerContext);
+      BasicConfigurator.configure(loggerContext);
     }
   }
-  
-  public static void autoConfig(LoggerContext loggerContext) {
+
+  public static void autoConfig(LoggerContext loggerContext)
+      throws JoranException {
     ClassLoader tccl = Loader.getTCL();
     autoConfig(loggerContext, tccl);
-   
+
   }
 }



More information about the logback-dev mailing list