[logback-dev] [GIT] Logback: the generic, reliable, fast and flexible logging framework. branch, encoder, updated. v0.9.18-51-g90e50c2

added by portage for gitosis-gentoo git-noreply at pixie.qos.ch
Mon Mar 1 19:15:07 CET 2010


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Logback: the generic, reliable, fast and flexible logging framework.".

The branch, encoder has been updated
       via  90e50c2f25dcacd6455af8baac5d8cfe6cf10f94 (commit)
      from  8381bae9d2899def5d9a9420edd2d53811ddba5b (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.qos.ch/gitweb/?p=logback.git;a=commit;h=90e50c2f25dcacd6455af8baac5d8cfe6cf10f94
http://github.com/ceki/logback/commit/90e50c2f25dcacd6455af8baac5d8cfe6cf10f94

commit 90e50c2f25dcacd6455af8baac5d8cfe6cf10f94
Author: Ceki Gulcu <ceki at qos.ch>
Date:   Mon Mar 1 19:13:40 2010 +0100

    - working on smoother transition from layout to encoder in FileAppender
    - added JNDIBasedContextDiscriminator which should work much better than
    ContextBasedtiscriminator.

diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/sift/ContextBasedDiscriminator.java b/logback-classic/src/main/java/ch/qos/logback/classic/sift/ContextBasedDiscriminator.java
index 03e6205..f0e6042 100644
--- a/logback-classic/src/main/java/ch/qos/logback/classic/sift/ContextBasedDiscriminator.java
+++ b/logback-classic/src/main/java/ch/qos/logback/classic/sift/ContextBasedDiscriminator.java
@@ -18,10 +18,11 @@ import ch.qos.logback.core.sift.Discriminator;
 import ch.qos.logback.core.spi.ContextAwareBase;
 
 /**
- * This discriminator essentially returns the value mapped to an MDC key. If the
- * said value is null, then a default value is returned.
+ * This discriminator returns the value context to which this event is attached
+ * to. If the said value is null, then a default value is returned.
  * 
- * <p>Both Key and the DefaultValue are user specified properties.
+ * <p>
+ * Both Key and the DefaultValue are user specified properties.
  * 
  * @author Ceki G&uuml;lc&uuml;
  * 
@@ -66,7 +67,8 @@ public class ContextBasedDiscriminator extends ContextAwareBase implements
   }
 
   public void setKey(String key) {
-    throw new UnsupportedOperationException("Key cannot be set. Using fixed key "+KEY);
+    throw new UnsupportedOperationException(
+        "Key cannot be set. Using fixed key " + KEY);
   }
 
   /**
diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/sift/ContextBasedDiscriminator.java b/logback-classic/src/main/java/ch/qos/logback/classic/sift/JNDIBasedContextDiscriminator.java
similarity index 69%
copy from logback-classic/src/main/java/ch/qos/logback/classic/sift/ContextBasedDiscriminator.java
copy to logback-classic/src/main/java/ch/qos/logback/classic/sift/JNDIBasedContextDiscriminator.java
index 03e6205..499c2f6 100644
--- a/logback-classic/src/main/java/ch/qos/logback/classic/sift/ContextBasedDiscriminator.java
+++ b/logback-classic/src/main/java/ch/qos/logback/classic/sift/JNDIBasedContextDiscriminator.java
@@ -13,40 +13,51 @@
  */
 package ch.qos.logback.classic.sift;
 
+import org.slf4j.impl.StaticLoggerBinder;
+
+import ch.qos.logback.classic.LoggerContext;
+import ch.qos.logback.classic.selector.ContextSelector;
 import ch.qos.logback.classic.spi.ILoggingEvent;
 import ch.qos.logback.core.sift.Discriminator;
 import ch.qos.logback.core.spi.ContextAwareBase;
 
 /**
- * This discriminator essentially returns the value mapped to an MDC key. If the
+ * This discriminator returns the value context as determined by JNDI. If the
  * said value is null, then a default value is returned.
  * 
- * <p>Both Key and the DefaultValue are user specified properties.
+ * <p>
+ * Both Key and the DefaultValue are user specified properties.
  * 
  * @author Ceki G&uuml;lc&uuml;
  * 
  */
-public class ContextBasedDiscriminator extends ContextAwareBase implements
+public class JNDIBasedContextDiscriminator extends ContextAwareBase implements
     Discriminator<ILoggingEvent> {
 
   private static final String KEY = "contextName";
   private String defaultValue;
   private boolean started = false;
 
-  public ContextBasedDiscriminator() {
+  public JNDIBasedContextDiscriminator() {
   }
 
   /**
    * Return the name of the current context name as found in the logging event.
    */
   public String getDiscriminatingValue(ILoggingEvent event) {
-    String contextName = event.getLoggerContextVO().getName();
+    ContextSelector selector = StaticLoggerBinder.getSingleton()
+        .getContextSelector();
 
-    if (contextName == null) {
+    if (selector == null) {
       return defaultValue;
-    } else {
-      return contextName;
     }
+
+    LoggerContext lc = selector.getLoggerContext();
+    if (lc == null) {
+      return defaultValue;
+    }
+
+    return lc.getName();
   }
 
   public boolean isStarted() {
@@ -66,7 +77,8 @@ public class ContextBasedDiscriminator extends ContextAwareBase implements
   }
 
   public void setKey(String key) {
-    throw new UnsupportedOperationException("Key cannot be set. Using fixed key "+KEY);
+    throw new UnsupportedOperationException(
+        "Key cannot be set. Using fixed key " + KEY);
   }
 
   /**
diff --git a/logback-core/src/main/java/ch/qos/logback/core/OutputStreamAppender.java b/logback-core/src/main/java/ch/qos/logback/core/OutputStreamAppender.java
index 1a38cac..c0c7b1f 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/OutputStreamAppender.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/OutputStreamAppender.java
@@ -85,6 +85,10 @@ public class OutputStreamAppender<E> extends UnsynchronizedAppenderBase<E> {
     }
   }
 
+  public void setLayout(Layout layout) {
+    addError("This appender no longer admits a layout as a sub-component, set an encoder instead.");
+  }
+
   @Override
   protected void append(E eventObject) {
     if (!isStarted()) {
diff --git a/logback-core/src/test/input/joran/compatibility/layoutInsteadOfEncoder.xml b/logback-core/src/test/input/joran/compatibility/layoutInsteadOfEncoder.xml
new file mode 100644
index 0000000..e69de29

-----------------------------------------------------------------------

Summary of changes:
 .../classic/sift/ContextBasedDiscriminator.java    |   10 ++++--
 ...tor.java => JNDIBasedContextDiscriminator.java} |   30 ++++++++++++++------
 .../ch/qos/logback/core/OutputStreamAppender.java  |    4 ++
 .../compatibility/layoutInsteadOfEncoder.xml}      |    0
 4 files changed, 31 insertions(+), 13 deletions(-)
 copy logback-classic/src/main/java/ch/qos/logback/classic/sift/{ContextBasedDiscriminator.java => JNDIBasedContextDiscriminator.java} (69%)
 copy logback-core/src/test/{witness/rolling/tbr-test1.0 => input/joran/compatibility/layoutInsteadOfEncoder.xml} (100%)


hooks/post-receive
-- 
Logback: the generic, reliable, fast and flexible logging framework.


More information about the logback-dev mailing list