[logback-dev] svn commit: r1290 - in logback/trunk/logback-classic/src: main/java/org/slf4j test/java/ch/qos/logback/classic/selector

noreply.seb at qos.ch noreply.seb at qos.ch
Mon Jan 29 18:56:56 CET 2007


Author: seb
Date: Mon Jan 29 18:56:55 2007
New Revision: 1290

Modified:
   logback/trunk/logback-classic/src/main/java/org/slf4j/LoggerFactory.java
   logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/selector/ContextDetachingSCLTest.java
   logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/selector/ContextJNDISelectorTest.java

Log:
Temporary situation

Modified: logback/trunk/logback-classic/src/main/java/org/slf4j/LoggerFactory.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/org/slf4j/LoggerFactory.java	(original)
+++ logback/trunk/logback-classic/src/main/java/org/slf4j/LoggerFactory.java	Mon Jan 29 18:56:55 2007
@@ -68,26 +68,8 @@
   private LoggerFactory() {
   }
 
-  static {
-    try {
-      //let's configure a default context
-      defaultLoggerContext = new LoggerContext();
-      defaultLoggerContext.setName("default");
-      ContextInitializer.autoConfig(defaultLoggerContext);
-      
-      //See if a special context selector is needed
-      String contextSelectorStr = OptionHelper.getSystemProperty(ClassicGlobal.LOGBACK_CONTEXT_SELECTOR, null);
-      if (contextSelectorStr == null) {
-        contextSelector = new DefaultContextSelector(defaultLoggerContext);
-      } else if (contextSelectorStr.equals("JNDI")) {
-        //if jndi is specified, let's use the appropriate class
-        contextSelector = new ContextJNDISelector(defaultLoggerContext);
-      }
-    } catch (Exception e) {
-      // we should never get here
-      Util.reportFailure("Failed to instantiate logger [" + LoggerContext.class
-          + "]", e);
-    }
+  static {       
+    setup();
   }
 
   /**
@@ -134,4 +116,26 @@
   public static ContextSelector getContextSelector() {
     return contextSelector;
   }
+  
+  public static void setup() {
+    try {
+      //let's configure a default context
+      defaultLoggerContext = new LoggerContext();
+      defaultLoggerContext.setName("default");
+      ContextInitializer.autoConfig(defaultLoggerContext);
+      
+      //See if a special context selector is needed
+      String contextSelectorStr = OptionHelper.getSystemProperty(ClassicGlobal.LOGBACK_CONTEXT_SELECTOR, null);
+      if (contextSelectorStr == null) {
+        contextSelector = new DefaultContextSelector(defaultLoggerContext);
+      } else if (contextSelectorStr.equals("JNDI")) {
+        //if jndi is specified, let's use the appropriate class
+        contextSelector = new ContextJNDISelector(defaultLoggerContext);
+      }
+    } catch (Exception e) {
+      // we should never get here
+      Util.reportFailure("Failed to instantiate logger [" + LoggerContext.class
+          + "]", e);
+    }
+  }
 }

Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/selector/ContextDetachingSCLTest.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/selector/ContextDetachingSCLTest.java	(original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/selector/ContextDetachingSCLTest.java	Mon Jan 29 18:56:55 2007
@@ -19,6 +19,8 @@
   @Override
   protected void setUp() throws Exception {
     System.setProperty(ClassicGlobal.LOGBACK_CONTEXT_SELECTOR, "JNDI");
+    LoggerFactory.setup();
+    
     listener = new ContextDetachingSCL();
     
     MockInitialContext mic = MockInitialContextFactory.getContext();

Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/selector/ContextJNDISelectorTest.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/selector/ContextJNDISelectorTest.java	(original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/selector/ContextJNDISelectorTest.java	Mon Jan 29 18:56:55 2007
@@ -18,8 +18,10 @@
   ContextDetachingSCL listener;
   
   @Override
-  protected void setUp() throws Exception {
+  protected void setUp() throws Exception {    
     System.setProperty(ClassicGlobal.LOGBACK_CONTEXT_SELECTOR, "JNDI");
+    LoggerFactory.setup();
+    
     listener = new ContextDetachingSCL();
     
     MockInitialContext mic = MockInitialContextFactory.getContext();



More information about the logback-dev mailing list