[logback-dev] [GIT] Logback: the generic, reliable, fast and flexible logging framework. branch, master, updated. v_0.9.21-16-g44a4433

added by portage for gitosis-gentoo git-noreply at pixie.qos.ch
Mon Jun 21 18:45:48 CEST 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, master has been updated
       via  44a4433972f33a39600893903028a6860341c5ac (commit)
      from  cf03337b10f4d987ffa47d00a904e2565b8975a9 (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=44a4433972f33a39600893903028a6860341c5ac
http://github.com/ceki/logback/commit/44a4433972f33a39600893903028a6860341c5ac

commit 44a4433972f33a39600893903028a6860341c5ac
Author: Ceki Gulcu <ceki at qos.ch>
Date:   Mon Jun 21 18:42:06 2010 +0200

    - documenting buffer tracking funtionality in SMTPAppender

diff --git a/logback-classic/integration.xml b/logback-classic/integration.xml
index a8a5b3a..552e918 100644
--- a/logback-classic/integration.xml
+++ b/logback-classic/integration.xml
@@ -23,12 +23,12 @@
 
 
 
-	<target name="testAll" depends="testWithoutGroovy">
+	<target name="testAll" depends="testWithoutGroovy" unless="maven.test.skip">
 	</target>
 
 
 
-	<target name="testWithoutGroovy">
+	<target name="testWithoutGroovy" unless="maven.test.skip">
 		<junit printsummary="yes" fork="no" haltonfailure="yes">
 			<classpath refid="basicClasspath" />
 			<formatter type="plain" />
diff --git a/logback-classic/pom.xml b/logback-classic/pom.xml
index 2d0ba69..f1605e0 100644
--- a/logback-classic/pom.xml
+++ b/logback-classic/pom.xml
@@ -282,8 +282,6 @@
           <execution>
             <id>ant-integration-test</id>
             <phase>package</phase>
-      
-
             <configuration>
               <tasks>      
                 <property name="slf4j.version" value="${slf4j.version}"/>
diff --git a/logback-classic/src/main/groovy/ch/qos/logback/classic/gaffer/ComponentDelegate.groovy b/logback-classic/src/main/groovy/ch/qos/logback/classic/gaffer/ComponentDelegate.groovy
index 0686228..b4e01b7 100644
--- a/logback-classic/src/main/groovy/ch/qos/logback/classic/gaffer/ComponentDelegate.groovy
+++ b/logback-classic/src/main/groovy/ch/qos/logback/classic/gaffer/ComponentDelegate.groovy
@@ -31,10 +31,6 @@ class ComponentDelegate extends ContextAwareBase {
     this.component = component;
   }
 
-  Object getDeclaredOrigin() {
-    return "ComponentDelegate"
-  }
-
   String getLabel() { "component" }
 
   String getLabelFistLetterInUpperCase() { getLabel()[0].toUpperCase() + getLabel().substring(1) }
@@ -79,7 +75,6 @@ class ComponentDelegate extends ContextAwareBase {
 
   void cascadeFields(ComponentDelegate subDelegate) {
     for (String k: fieldsToCaccade) {
-      println "cacsading ${k} with value ${this."${k}"}"
       subDelegate.metaClass."${k}" = this."${k}"
     }
   }
diff --git a/logback-classic/src/main/groovy/ch/qos/logback/classic/gaffer/ConfigurationDelegate.groovy b/logback-classic/src/main/groovy/ch/qos/logback/classic/gaffer/ConfigurationDelegate.groovy
index 5bda299..08d3c73 100644
--- a/logback-classic/src/main/groovy/ch/qos/logback/classic/gaffer/ConfigurationDelegate.groovy
+++ b/logback-classic/src/main/groovy/ch/qos/logback/classic/gaffer/ConfigurationDelegate.groovy
@@ -40,8 +40,7 @@ public class ConfigurationDelegate extends ContextAwareBase {
 
 
   Object getDeclaredOrigin() {
-    //println "ConfigurationDelegate"
-    return "ConfigurationDelegate"
+    return this;
   }
 
   void scan(String scanPeriodStr = null) {
@@ -131,6 +130,11 @@ public class ConfigurationDelegate extends ContextAwareBase {
     appender.start();
   }
 
+
+  public void toto(String m) {
+    println "xxxxxxxxxxxxxxxxxxxx "+m;
+  }
+
   private void copyContributions(AppenderDelegate appenderDelegate, Appender appender) {
     if(appender instanceof ConfigurationContributor) {
       ConfigurationContributor cc = (ConfigurationContributor) appender;
diff --git a/logback-core/src/main/java/ch/qos/logback/core/net/SMTPAppenderBase.java b/logback-core/src/main/java/ch/qos/logback/core/net/SMTPAppenderBase.java
index 43e34e6..db5156d 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/net/SMTPAppenderBase.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/net/SMTPAppenderBase.java
@@ -58,6 +58,13 @@ import ch.qos.logback.core.util.OptionHelper;
  */
 public abstract class SMTPAppenderBase<E> extends AppenderBase<E> {
 
+
+  // ~ 14 days
+  static final int MAX_DELAY_BETWEEN_STATUS_MESSAGES = 1228800 * CoreConstants.MILLIS_IN_ONE_SECOND;
+
+  long lastTrackerStatusPrint = 0;
+  int delayBetweenStatusMessages = 300 * CoreConstants.MILLIS_IN_ONE_SECOND;
+
   protected Layout<E> subjectLayout;
 
   protected Layout<E> layout;
@@ -159,11 +166,9 @@ public abstract class SMTPAppenderBase<E> extends AppenderBase<E> {
       return;
     }
 
-
-    String key =  discriminator.getDiscriminatingValue(eventObject);
-
-    CyclicBuffer<E> cb = cbTracker.get(key, System.currentTimeMillis());
-
+    String key = discriminator.getDiscriminatingValue(eventObject);
+    long now = System.currentTimeMillis();
+    CyclicBuffer<E> cb = cbTracker.get(key, now);
     subAppend(cb, eventObject);
 
     try {
@@ -176,6 +181,15 @@ public abstract class SMTPAppenderBase<E> extends AppenderBase<E> {
         addError("SMTPAppender's EventEvaluator threw an Exception-", ex);
       }
     }
+    cbTracker.clearStaleBuffers(now);
+    if (lastTrackerStatusPrint + delayBetweenStatusMessages < now) {
+      addInfo("SMTPAppender [" + name + "] is tracking [" + cbTracker.size() + "] buffers");
+      lastTrackerStatusPrint = now;
+      // quadruple 'delay' assuming less than max delay 
+      if (delayBetweenStatusMessages < MAX_DELAY_BETWEEN_STATUS_MESSAGES) {
+        delayBetweenStatusMessages *= 4;
+      }
+    }
   }
 
   abstract protected void subAppend(CyclicBuffer<E> cb, E eventObject);
diff --git a/logback-core/src/main/java/ch/qos/logback/core/spi/CyclicBufferTracker.java b/logback-core/src/main/java/ch/qos/logback/core/spi/CyclicBufferTracker.java
index db82b74..4f1ab45 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/spi/CyclicBufferTracker.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/spi/CyclicBufferTracker.java
@@ -58,8 +58,14 @@ public interface CyclicBufferTracker<E> {
 
   /**
    * Clear (and detach) buffers which are stale.
-   * 
+   *
    * @param now
    */
   void clearStaleBuffers(long now);
+
+  /**
+   * The size of the internal map/list/collection holding the cyclic buffers.
+   * @return  size of internal collection
+   */
+  int size();
 }
diff --git a/logback-core/src/main/java/ch/qos/logback/core/spi/CyclicBufferTrackerImpl.java b/logback-core/src/main/java/ch/qos/logback/core/spi/CyclicBufferTrackerImpl.java
index f71813c..c424b61 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/spi/CyclicBufferTrackerImpl.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/spi/CyclicBufferTrackerImpl.java
@@ -31,12 +31,18 @@ public class CyclicBufferTrackerImpl<E> implements CyclicBufferTracker<E> {
   int maxNumBuffers = DEFAULT_NUMBER_OF_BUFFERS;
   int bufferCount = 0;
 
+  // 5 minutes
+  static final int DELAY_BETWEEN_CLEARING_STALE_BUFFERS = 300*CoreConstants.MILLIS_IN_ONE_SECOND ;
+
+ 
+
   private Map<String, Entry> map = new HashMap<String, Entry>();
 
   private Entry head; // least recently used entries are towards the head
   private Entry tail; // most recently used entries are towards the tail
   long lastCheck = 0;
 
+
   public CyclicBufferTrackerImpl() {
     head = new Entry(null, null, 0);
     tail = head;
@@ -111,10 +117,11 @@ public class CyclicBufferTrackerImpl<E> implements CyclicBufferTracker<E> {
 
 
   public synchronized void clearStaleBuffers(long now) {
-    if (lastCheck + CoreConstants.MILLIS_IN_ONE_SECOND > now) {
+    if (lastCheck + DELAY_BETWEEN_CLEARING_STALE_BUFFERS > now) {
       return;
     }
     lastCheck = now;
+
     while (head.value != null && isEntryStale(head, now)) {
       CyclicBuffer<E> cb = head.value;
       cb.clear();
@@ -122,6 +129,10 @@ public class CyclicBufferTrackerImpl<E> implements CyclicBufferTracker<E> {
     }
   }
 
+  public int size() {
+    return map.size();
+  }
+
   final private boolean isEntryStale(Entry entry, long now) {
     return ((entry.timestamp + THRESHOLD) < now);
   }
diff --git a/logback-core/src/main/java/ch/qos/logback/core/status/ViewStatusMessagesServletBase.java b/logback-core/src/main/java/ch/qos/logback/core/status/ViewStatusMessagesServletBase.java
index 53216d2..fc3f6a0 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/status/ViewStatusMessagesServletBase.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/status/ViewStatusMessagesServletBase.java
@@ -35,6 +35,9 @@ abstract public class ViewStatusMessagesServletBase extends HttpServlet {
   private static SimpleDateFormat SDF = new SimpleDateFormat(
       "yyyy-MM-dd HH:mm:ss");
 
+  static String SUBMIT = "submit";
+  static String CLEAR = "Clear";
+
   protected abstract StatusManager getStatusManager(HttpServletRequest req, HttpServletResponse resp);
 
   protected abstract String getPageTitle(HttpServletRequest req, HttpServletResponse resp);
@@ -44,7 +47,6 @@ abstract public class ViewStatusMessagesServletBase extends HttpServlet {
   protected void service(HttpServletRequest req, HttpServletResponse resp)
       throws ServletException, IOException {
 
-    System.out.println("service called");
     count = 0;
     StatusManager sm = getStatusManager(req, resp);
 
@@ -58,6 +60,17 @@ abstract public class ViewStatusMessagesServletBase extends HttpServlet {
     output.append("<body>\r\n");
     output.append(getPageTitle(req, resp));
 
+
+    output.append("<form method=\"POST\">\r\n");
+    output.append("<input type=\"submit\" name=\""+SUBMIT+"\" value=\""+CLEAR+"\">");
+    output.append("</form>\r\n");
+
+
+    if(CLEAR.equalsIgnoreCase(req.getParameter(SUBMIT))) {
+      sm.clear();
+      sm.add(new InfoStatus("Cleared all status messages", this));
+    }
+    
     output.append("<table>");
     StringBuilder buf = new StringBuilder();
     if(sm != null) {
diff --git a/logback-core/src/test/java/ch/qos/logback/core/spi/CyclicBufferTracker_TImpl.java b/logback-core/src/test/java/ch/qos/logback/core/spi/CyclicBufferTracker_TImpl.java
index fd56075..553104d 100644
--- a/logback-core/src/test/java/ch/qos/logback/core/spi/CyclicBufferTracker_TImpl.java
+++ b/logback-core/src/test/java/ch/qos/logback/core/spi/CyclicBufferTracker_TImpl.java
@@ -51,7 +51,7 @@ public class CyclicBufferTracker_TImpl<E> implements CyclicBufferTracker<E> {
     TEntry te = getEntry(key);
     if (te == null) {
       CyclicBuffer<E> cb = new CyclicBuffer<E>(bufferSize);
-      te = new  TEntry<E>(key, cb, timestamp);
+      te = new TEntry<E>(key, cb, timestamp);
       entryList.add(te);
       return cb;
     } else {
@@ -67,7 +67,7 @@ public class CyclicBufferTracker_TImpl<E> implements CyclicBufferTracker<E> {
   }
 
   public void clearStaleBuffers(long now) {
-   if (lastCheck + CoreConstants.MILLIS_IN_ONE_SECOND > now) {
+    if (lastCheck + CoreConstants.MILLIS_IN_ONE_SECOND > now) {
       return;
     }
     lastCheck = now;
@@ -77,6 +77,11 @@ public class CyclicBufferTracker_TImpl<E> implements CyclicBufferTracker<E> {
     }
   }
 
+  public int size() {
+    return entryList.size();
+  }
+
+
   // ==================================================================
 
   private class TEntry<E> implements Comparable {
diff --git a/logback-examples/src/main/java/chapters/appenders/mail/mail3.xml b/logback-examples/src/main/java/chapters/appenders/mail/mail3.xml
index 342de5d..01b1832 100644
--- a/logback-examples/src/main/java/chapters/appenders/mail/mail3.xml
+++ b/logback-examples/src/main/java/chapters/appenders/mail/mail3.xml
@@ -8,7 +8,6 @@
 <configuration>
   <appender name="EMAIL" class="ch.qos.logback.classic.net.SMTPAppender">
     <Evaluator class="chapters.appenders.mail.CounterBasedEvaluator" />
-    <BufferSize>1050</BufferSize>
     <SMTPHost>${smtpHost}</SMTPHost>
     <To>${to}</To>
     <From>${from}</From>
diff --git a/logback-examples/src/main/java/chapters/appenders/mail/mailWithMDCBasedDiscriminator.xml b/logback-examples/src/main/java/chapters/appenders/mail/mailWithMDCBasedDiscriminator.xml
new file mode 100644
index 0000000..624684e
--- /dev/null
+++ b/logback-examples/src/main/java/chapters/appenders/mail/mailWithMDCBasedDiscriminator.xml
@@ -0,0 +1,27 @@
+
+<configuration>
+  <appender name="EMAIL" class="ch.qos.logback.classic.net.SMTPAppender">
+
+    <SMTPHost>ADDRESS-OF-YOUR-SMTP-HOST</SMTPHost>
+    <to>EMAIL-DESTINATION</to>
+    <from>SENDER-EMAIL</from>
+
+
+    <discriminator class="ch.qos.logback.classic.sift.MDCBasedDiscriminator">
+      <key>req.remoteHost</key>
+      <defaultValue>default</defaultValue>
+    </discriminator>
+
+    <subject>${HOSTNAME} -- %X{req.remoteHost} %msg"</subject>
+    <layout class="ch.qos.logback.classic.html.HTMLLayout">
+      <pattern>%date%level%thread%X{req.remoteHost}%X{req.requestURL}%X{req.queryString}%logger%msg</pattern>
+    </layout>
+  </appender>
+
+  <root>
+    <level level="DEBUG"/>
+    <appender-ref ref="EMAIL" />
+  </root>  
+</configuration>
+
+
diff --git a/logback-examples/src/main/java/chapters/appenders/mail/mailWithMarker.xml b/logback-examples/src/main/java/chapters/appenders/mail/mailWithMarker.xml
index c1c7127..4095d5b 100644
--- a/logback-examples/src/main/java/chapters/appenders/mail/mailWithMarker.xml
+++ b/logback-examples/src/main/java/chapters/appenders/mail/mailWithMarker.xml
@@ -7,7 +7,6 @@
       <!-- you specify add as many markers as you want -->
       <marker>ANOTHER_MARKER</marker>
     </evaluator>
-    <BufferSize>1050</BufferSize>
     <SMTPHost>${smtpHost}</SMTPHost>
     <To>${to}</To>
     <From>${from}</From>
diff --git a/logback-site/src/site/pages/manual/appenders.html b/logback-site/src/site/pages/manual/appenders.html
index 232775b..4a9b92c 100644
--- a/logback-site/src/site/pages/manual/appenders.html
+++ b/logback-site/src/site/pages/manual/appenders.html
@@ -2141,10 +2141,11 @@ Context ctx = new InitialContext(env);</pre>
 
    <p>The <a
    href="../xref/ch/qos/logback/classic/net/SMTPAppender.html"><code>SMTPAppender</code></a>
-   accumulates logging events in a fixed-size buffer and sends them in
-   an email after a user-specified event occurs.  By default, the
-   email transmission is triggered by a logging event of level ERROR
-   or higher.
+   accumulates logging events in one or more fixed-size buffers and
+   sends the contents of the appropriate bugger in an email after a
+   user-specified event occurs.  By default, the email transmission is
+   triggered by a logging event of level ERROR or higher. Moreover, by
+   default, a single buffer is used for all events.
    </p>
 		
    <p>The various properties for <code>SMTPAppender</code> are
@@ -2210,20 +2211,30 @@ Context ctx = new InitialContext(env);</pre>
         </td>
       </tr>
       <tr class="alt">
-        <td><b><span class="option">BufferSize</span></b></td>
-        <td><code>int</code></td>
+
+
+        <td><b><span class="option">Discriminator</span></b></td>
+        <td><code><a href="../xref/ch/qos/logback/core/sift/Discriminator.html">Discriminator</a></code></td>
         <td>
-          The <span class="option">BufferSize</span> option takes a
-          positive integer representing the maximum number of logging
-          events to collect in a cyclic buffer. When the <span
-          class="option">BufferSize</span> is reached, oldest events
-          are deleted as new events are added to the buffer.  The
-          default size of the cyclic buffer is 512.
+          <p>With the help of a <span
+          class="option">Discriminator</span>,
+          <code>SMTPAppender</code> can scatter incoming events into
+          different buffers according to the value returned by the
+          discriminator. The default discriminator always returns the
+          same value so that the same buffer is used for all events.
+          </p>
+
+          <p>By specifiying a discriminator other than the default
+          one, it would be possible to receive email messages
+          containing a events pertaining to a particular user, user
+          session or client IP address.
+          </p>
         </td>
       </tr>
       <tr >
         <td><b><span class="option">Evaluator</span></b></td>
-        <td><code>String</code></td>
+        <td><code><a
+        href="../xref/ch/qos/logback/classic/boolex/IEvaluator.html">IEvaluator</a></code></td>
         <td>
           <p>This option is declared by creating a new
           <code>&lt;EventEvaluator/></code> element. The name of the
@@ -2294,14 +2305,12 @@ Context ctx = new InitialContext(env);</pre>
 
 		</table>		
 		
-		<p>The SMTPAppender keeps only the last <span
-		class="option">BufferSize</span> logging events in its cyclic
-		buffer, throwing away older events when its buffer becomes full.
-		Thus, the number of logging events delivered in any e-mail sent by
-		<code>SMTPAppender</code> is upper-bounded by <span
-		class="option">BufferSize</span>. This keeps memory requirements
-		bounded while still delivering a reasonable amount of application
-		context.
+		<p>The <code>SMTPAppender</code> keeps only the last 256 logging
+		events in its cyclic buffer, throwing away older events when its
+		buffer becomes full.  Thus, the number of logging events delivered
+		in any e-mail sent by <code>SMTPAppender</code> is upper-bounded
+		by 256. This keeps memory requirements bounded while still
+		delivering a reasonable amount of application context.
 		</p>
 		
 		<p>The <code>SMTPAppender</code> relies on the JavaMail API.  It
@@ -2316,7 +2325,6 @@ Context ctx = new InitialContext(env);</pre>
 		the following examples.
 		</p>
 		
-
 		<p>A sample application, <a
 		href="../xref/chapters/appenders/mail/EMail.html"><code>chapters.appenders.mail.EMail</code></a>
 		generates a number of log messages messages followed by a single
@@ -2359,10 +2367,10 @@ Context ctx = new InitialContext(env);</pre>
 		configuration file, execute the following command:
 		</p>
 		
-<div class="source"><pre>java chapters.appenders.mail.EMail 300 src/main/java/chapters/appenders/mail/mail1.xml</pre></div>
+<div class="source"><pre>java chapters.appenders.mail.EMail 100 src/main/java/chapters/appenders/mail/mail1.xml</pre></div>
 
 		<p>The recipient you specified should receive an email message
-		containing 300 logging events formatted by
+		containing 100 logging events formatted by
 		<code>PatternLayout</code> The figure below is the resulting email
 		message as shown by Mozilla Thunderbird.
 		</p>
@@ -2401,12 +2409,12 @@ Context ctx = new InitialContext(env);</pre>
 		for further details.
     </p>
     
-    <p>Given that the default size of the cyclic buffer is 512, the
-    recipient should see an email message containing 512 events
-    conveniently formatted in an HTML table. Note that this run of the
-    <code>chapters.appenders.mail.Email</code> application generated 10'000
-    events of which only the last 512 were included in the outgoing
-    email.
+    <p>Given that the size of the cyclic buffer is 256, the recipient
+    should see an email message containing 256 events conveniently
+    formatted in an HTML table. Note that this run of the
+    <code>chapters.appenders.mail.Email</code> application generated
+    10'000 events of which only the last 256 were included in the
+    outgoing email.
 		</p>
 		
     <p><img src="images/chapters/appenders/smtpAppender2.jpg" alt="2nd email"/></p>
@@ -2495,8 +2503,8 @@ public class CounterBasedEvaluator extends ContextAwareBase implements EventEval
 		<p>Setting the <span class="option">Evaluator</span> option of
 		<code>SMTPAppender</code> instructs it to use a custom evaluator.
 		The next configuration file attaches a <code>SMTPAppender</code>
-		to the root logger.  This appender has a buffer size of 2048 and
-		uses a <code>CounterBasedEvaluator</code> instance as its event
+		to the root logger.  This appender uses a
+		<code>CounterBasedEvaluator</code> instance as its event
 		evaluator.
 		</p>
 
@@ -2506,7 +2514,6 @@ public class CounterBasedEvaluator extends ContextAwareBase implements EventEval
     <pre id="mail3" class="prettyprint source">&lt;configuration>
   &lt;appender name="EMAIL" class="ch.qos.logback.classic.net.SMTPAppender">
     <b>&lt;Evaluator class="chapters.appenders.mail.CounterBasedEvaluator" /></b>
-    &lt;BufferSize>1050&lt;/BufferSize>
     &lt;SMTPHost>${smtpHost}&lt;/SMTPHost>
     &lt;To>${to}&lt;/To>
     &lt;From>${from}&lt;/From>
@@ -2560,7 +2567,6 @@ logger.error(<b>notifyAdminMarker</b>,
       &lt;!-- you specify add as many markers as you want -->
       &lt;marker>TRANSACTION_FAILURE&lt;/marker>
     &lt;/evaluator></b>
-    &lt;BufferSize>1050&lt;/BufferSize>
     &lt;SMTPHost>${smtpHost}&lt;/SMTPHost>
     &lt;To>${to}&lt;/To>
     &lt;From>${from}&lt;/From>
@@ -2658,6 +2664,61 @@ logger.error(<b>notifyAdminMarker</b>,
 &lt;/configuration></pre>
 
 
+    <h3><a name="smtpDiscriminator"
+    href="#smtpDiscriminator">SMTPAppender with
+    MDCDiscriminator</a></h3>
+
+    <p>As mentioned earlier, by specifiying a discriminator other than
+    the default one, SMTPAppender will generate email messages
+    containing events pertaining to a particular user, user session or
+    client IP address, depending on the discriminator.
+    </p>
+
+    <p>The next example uses <a
+    href="../xref/ch/qos/logback/classic/sift/MDCBasedDiscriminator.html">MDCBasedDsicriminator</a>
+    focused on the MDC key named "req.remoteHost" which is assumed to
+    contain the IP address of the remote host accessing a fictitious
+    application. In a web-application, you could use <a
+    href="mdc.html#mis">MDCInsertingServletFilter</a> to populate MDC
+    values.
+    </p>
+
+    <p class="example">Example: <code>SMTPAppender</code> with
+    MDCBasedDsicriminator
+    (logback-examples/src/main/java/chapters/appenders/mail/mailWithMDCBasedDiscriminator.xml)</p>
+
+    <span class="asGroovy" onclick="return asGroovy('mailWithMDCBasedDiscriminator');">View as .grovvy</span>	
+    <pre id="mailWithMDCBasedDiscriminator" class="prettyprint source">&lt;configuration>	  
+  &lt;appender name="EMAIL" class="ch.qos.logback.classic.net.SMTPAppender">
+    &lt;SMTPHost>ADDRESS-OF-YOUR-SMTP-HOST&lt;/SMTPHost>
+    &lt;to>EMAIL-DESTINATION&lt;/to>
+    &lt;from>SENDER-EMAIL&lt;/from>
+
+    <b>&lt;discriminator class="ch.qos.logback.classic.sift.MDCBasedDiscriminator"></b>
+      <b>&lt;key>req.remoteHost&lt;/key></b>
+      <b>&lt;defaultValue>default&lt;/defaultValue></b>
+    <b>&lt;/discriminator></b>
+
+    &lt;subject>${HOSTNAME} -- %X{req.remoteHost} %msg"&lt;/subject>
+    &lt;layout class="ch.qos.logback.classic.html.HTMLLayout">
+      &lt;pattern>%date%level%thread%X{req.remoteHost}%X{req.requestURL}%logger%msg&lt;/pattern>
+    &lt;/layout>
+  &lt;/appender>
+
+  &lt;root>
+    &lt;level level="DEBUG"/>
+    &lt;appender-ref ref="EMAIL" />
+  &lt;/root>  
+&lt;/configuration></pre>
+
+    <p>Thus, each outgoing emails generated by
+    <code>SMTPAppender</code> will belong to a <em>unique</em> remote
+    host, greatly facilitating problem diagnosis.
+    </p>
+    
+    <!-- =========================================================== -->
+    <!-- =========================================================== -->
+
 
     <h3>
       <a name="DBAppender" href="#DBAppender">DBAppender</a>
diff --git a/logback-site/src/site/pages/manual/groovy.html b/logback-site/src/site/pages/manual/groovy.html
index 81be827..46e7f1d 100644
--- a/logback-site/src/site/pages/manual/groovy.html
+++ b/logback-site/src/site/pages/manual/groovy.html
@@ -70,8 +70,8 @@
     programs. And since groovy is a super-set of Java, whatever
     configuration actions you can perform in Java, you can do the same
     within a <em>logback.groovy</em> file. However, since configuring
-    logback progammatically using Java syntax can be very cumbersome,
-    we added a few logback-specific extensions to make your life
+    logback progammatically using Java syntax can be cumbersome, we
+    added a few logback-specific extensions to make your life
     easier. We try hard to limit the number of logback-specific
     syntactic extensions to an absolute minimum. If you are already
     familiar with groovy, you should be able to read, understand and
@@ -81,6 +81,11 @@
     <em>logback.xml</em>.
     </p>
 
+    <p>Given that <em>logback.groovy</em> files are groovy programs
+    with minimal logback-specific extensins, <em>all</em> the usual
+    groovy constructs such as class imports, variable definitions,
+    if-else statements are avaiable in <em>logback.groovy</em> files.</p>
+
     <p><em>Logback.groovy</em> syntax consists of half a dozen methods
     described next in the reverse order of their customary
     appearance. Strictly speaking, the order of invocation of these
diff --git a/logback-site/src/site/pages/news.html b/logback-site/src/site/pages/news.html
index d9e4272..446a827 100644
--- a/logback-site/src/site/pages/news.html
+++ b/logback-site/src/site/pages/news.html
@@ -29,7 +29,7 @@
 
       <hr width="80%" align="center" />
 
-    <h3>June 2xth, 2010 - Release of version 0.9.22</h3>
+    <h3>June 21st, 2010 - Release of version 0.9.22</h3>
 
     <p>Logback now supports <a href="manual/groovy.html">configuration
     files written in Groovy</a> which are more convenient than
@@ -39,6 +39,13 @@
     migrate your logback.xml files to logback.groovy</a>.
     </p>
 
+    <p>Inspired by the functionality offered by
+    <code>SiftingAppender</code>, <code>SMTPApppender</code> now can
+    <a href="manual/appenders.html#smtpDiscriminator">track multiple
+    buffers according to selection informaiton returned by a
+    discriminator</a>.
+    </p>
+
     <p>Fixed synchronization issue in <code>ConsoleAppender</code> as
     reported in <a
     href="http://jira.qos.ch/browse/LBCORE-158">LBCORE-158</a> by

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

Summary of changes:
 logback-classic/integration.xml                    |    4 +-
 logback-classic/pom.xml                            |    2 -
 .../classic/gaffer/ComponentDelegate.groovy        |    5 -
 .../classic/gaffer/ConfigurationDelegate.groovy    |    8 +-
 .../ch/qos/logback/core/net/SMTPAppenderBase.java  |   24 +++-
 .../qos/logback/core/spi/CyclicBufferTracker.java  |    8 +-
 .../logback/core/spi/CyclicBufferTrackerImpl.java  |   13 ++-
 .../core/status/ViewStatusMessagesServletBase.java |   15 ++-
 .../core/spi/CyclicBufferTracker_TImpl.java        |    9 +-
 .../main/java/chapters/appenders/mail/mail3.xml    |    1 -
 .../mail/mailWithMDCBasedDiscriminator.xml         |   27 ++++
 .../chapters/appenders/mail/mailWithMarker.xml     |    1 -
 logback-site/src/site/pages/manual/appenders.html  |  129 ++++++++++++++-----
 logback-site/src/site/pages/manual/groovy.html     |    9 +-
 logback-site/src/site/pages/news.html              |    9 ++-
 15 files changed, 204 insertions(+), 60 deletions(-)
 create mode 100644 logback-examples/src/main/java/chapters/appenders/mail/mailWithMDCBasedDiscriminator.xml


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


More information about the logback-dev mailing list