[logback-dev] [GIT] Logback: the generic, reliable, fast and flexible logging framework. branch master updated. v_1.0.3-2-g63ee4e4

Gitbot git-noreply at pixie.qos.ch
Sat May 5 13:08:50 CEST 2012


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  63ee4e4e0bad23f83cffb635147b377dc2fe3f30 (commit)
      from  6c689df7851d20f99afe56ed9379551c141cf0b1 (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=63ee4e4e0bad23f83cffb635147b377dc2fe3f30
http://github.com/ceki/logback/commit/63ee4e4e0bad23f83cffb635147b377dc2fe3f30

commit 63ee4e4e0bad23f83cffb635147b377dc2fe3f30
Author: Ceki Gulcu <ceki at qos.ch>
Date:   Sat May 5 13:07:20 2012 +0200

    SMTPAppender now admits the asynchronousSending property

diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/issue/lbclassic232/Simple.java b/logback-classic/src/test/java/ch/qos/logback/classic/issue/lbclassic232/Simple.java
deleted file mode 100644
index a700160..0000000
--- a/logback-classic/src/test/java/ch/qos/logback/classic/issue/lbclassic232/Simple.java
+++ /dev/null
@@ -1,34 +0,0 @@
-package ch.qos.logback.classic.issue.lbclassic232;
-
-import ch.qos.logback.classic.LoggerContext;
-import ch.qos.logback.classic.joran.JoranConfigurator;
-import ch.qos.logback.core.joran.spi.JoranException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class Simple {
-
-  static Logger logger = LoggerFactory.getLogger(Simple.class);
-  static String DIR_PREFIX = "src/test/java/ch/qos/logback/classic/issue/lbclassic232/";
-
-   public static void main(String[] args) throws JoranException, InterruptedException {
-     init(DIR_PREFIX + "logback_smtp.xml");
-
-     for (int i = 0; i < 10; i++) {
-       logger.debug("SEE IF THIS IS LOGGED {}.", i);
-     }
-
-     logger.error("trigger");
-
-   }
-
-
-   static void init(String file)  throws JoranException {
-     LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();
-       JoranConfigurator jc = new JoranConfigurator();
-       jc.setContext(loggerContext);
-       loggerContext.reset();
-       jc.doConfigure(file);
-   }
-
-}
diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/issue/lbclassic232/Barebones.java b/logback-classic/src/test/java/ch/qos/logback/classic/issue/lbclassic323/Barebones.java
similarity index 93%
rename from logback-classic/src/test/java/ch/qos/logback/classic/issue/lbclassic232/Barebones.java
rename to logback-classic/src/test/java/ch/qos/logback/classic/issue/lbclassic323/Barebones.java
index f8cdf56..9704d96 100644
--- a/logback-classic/src/test/java/ch/qos/logback/classic/issue/lbclassic232/Barebones.java
+++ b/logback-classic/src/test/java/ch/qos/logback/classic/issue/lbclassic323/Barebones.java
@@ -1,4 +1,4 @@
-package ch.qos.logback.classic.issue.lbclassic232;
+package ch.qos.logback.classic.issue.lbclassic323;
 
 import ch.qos.logback.core.Context;
 import ch.qos.logback.core.ContextBase;
diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/issue/lbclassic323/Simple.java b/logback-classic/src/test/java/ch/qos/logback/classic/issue/lbclassic323/Simple.java
new file mode 100644
index 0000000..625c61d
--- /dev/null
+++ b/logback-classic/src/test/java/ch/qos/logback/classic/issue/lbclassic323/Simple.java
@@ -0,0 +1,34 @@
+package ch.qos.logback.classic.issue.lbclassic323;
+
+import ch.qos.logback.classic.LoggerContext;
+import ch.qos.logback.classic.joran.JoranConfigurator;
+import ch.qos.logback.core.joran.spi.JoranException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class Simple {
+
+  static Logger logger = LoggerFactory.getLogger(Simple.class);
+  static String DIR_PREFIX = "src/test/java/ch/qos/logback/classic/issue/lbclassic323/";
+
+  public static void main(String[] args) throws JoranException, InterruptedException {
+    init(DIR_PREFIX + "logback_smtp.xml");
+
+    for (int i = 0; i < 10; i++) {
+      logger.debug("SEE IF THIS IS LOGGED {}.", i);
+    }
+    logger.error("trigger");
+    System.out.println("done");
+    System.exit(0);
+  }
+
+
+  static void init(String file) throws JoranException {
+    LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();
+    JoranConfigurator jc = new JoranConfigurator();
+    jc.setContext(loggerContext);
+    loggerContext.reset();
+    jc.doConfigure(file);
+  }
+
+}
diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/issue/lbclassic232/logback_smtp.xml b/logback-classic/src/test/java/ch/qos/logback/classic/issue/lbclassic323/logback_smtp.xml
similarity index 90%
rename from logback-classic/src/test/java/ch/qos/logback/classic/issue/lbclassic232/logback_smtp.xml
rename to logback-classic/src/test/java/ch/qos/logback/classic/issue/lbclassic323/logback_smtp.xml
index 6b39693..12b3bb7 100644
--- a/logback-classic/src/test/java/ch/qos/logback/classic/issue/lbclassic232/logback_smtp.xml
+++ b/logback-classic/src/test/java/ch/qos/logback/classic/issue/lbclassic323/logback_smtp.xml
@@ -8,6 +8,7 @@
     <subject>%logger{20} - %m</subject>
     <username>${destination}</username>
     <SSL>true</SSL>
+    <asynchronousSending>true</asynchronousSending>
     <layout class="ch.qos.logback.classic.PatternLayout">
       <pattern>%date %-5level %logger{35} - %message%n</pattern>
     </layout>
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 68365ec..e4f1cd1 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
@@ -191,9 +191,14 @@ public abstract class SMTPAppenderBase<E> extends AppenderBase<E> {
         // see http://jira.qos.ch/browse/LBCLASSIC-221
         cb.clear();
 
-        // perform actual sending asynchronously
-        SenderRunnable senderRunnable = new SenderRunnable(cbClone, eventObject);
-        context.getExecutorService().execute(senderRunnable);
+        if(asynchronousSending) {
+          // perform actual sending asynchronously
+          SenderRunnable senderRunnable = new SenderRunnable(cbClone, eventObject);
+          context.getExecutorService().execute(senderRunnable);
+        } else {
+          // synchronous sending
+          sendBuffer(cbClone, eventObject);
+        }
       }
     } catch (EvaluationException ex) {
       errorCount++;
@@ -499,6 +504,20 @@ public abstract class SMTPAppenderBase<E> extends AppenderBase<E> {
     this.discriminator = discriminator;
   }
 
+  public boolean isAsynchronousSending() {
+    return asynchronousSending;
+  }
+
+  /**
+   * By default, SMTAppender transmits emails asynchronously. For synchronous email transmission set
+   * asynchronousSending to 'false'.
+   * @param asynchronousSending  determines whether sending is done asynchronously or not
+   * @since 1.0.4
+   */
+  public void setAsynchronousSending(boolean asynchronousSending) {
+    this.asynchronousSending = asynchronousSending;
+  }
+
   public void addTo(String to) {
     if (to == null || to.length() == 0) {
       throw new IllegalArgumentException("Null or empty <to> property");
diff --git a/logback-site/src/site/pages/mailinglist.html b/logback-site/src/site/pages/mailinglist.html
index 821e3e3..c702465 100644
--- a/logback-site/src/site/pages/mailinglist.html
+++ b/logback-site/src/site/pages/mailinglist.html
@@ -144,15 +144,8 @@
 			</tr>
 		</table>
 
-
    <p> </p>
 
-   <h2>On IRC</h2>
-
-   <p>We can also be reached on IRC at <span
-      class="big"><code>irc.freenode.net#qos.ch</code></span>. </p>
-   
-   <p> </p>
 	
   <script src="templates/footer.js" type="text/javascript"></script>
 </div>
diff --git a/logback-site/src/site/pages/manual/appenders.html b/logback-site/src/site/pages/manual/appenders.html
index 3574056..2df02b0 100644
--- a/logback-site/src/site/pages/manual/appenders.html
+++ b/logback-site/src/site/pages/manual/appenders.html
@@ -1767,7 +1767,7 @@ public interface TriggeringPolicy<E> extends LifeCycle {
         <td>The host name of the SMTP server. This parameter is mandatory.</td>
       </tr>
       
-      <tr class="alt">
+      <tr>
         <td><b><span class="prop">smtpPort</span></b></td>
         <td><code>int</code></td>
         <td>The port where the SMTP server is listening. Defaults to
@@ -1787,7 +1787,7 @@ public interface TriggeringPolicy<E> extends LifeCycle {
         </td>
       </tr>
 
-      <tr class="alt">
+      <tr>
         <td><b><span class="prop">from</span></b></td>
         <td><code>String</code></td>
         <td>The originator of the email messages sent by
@@ -1826,7 +1826,7 @@ public interface TriggeringPolicy<E> extends LifeCycle {
         </td>
         
       </tr>
-      <tr class="alt">
+      <tr>
         <td><b><span class="prop">discriminator</span></b></td>
         <td><code><a href="../xref/ch/qos/logback/core/sift/Discriminator.html">Discriminator</a></code></td>
         <td>
@@ -1845,7 +1845,7 @@ public interface TriggeringPolicy<E> extends LifeCycle {
           </p>
         </td>
       </tr>
-      <tr >
+      <tr>
         <td><b><span class="prop"><a name="smtpAppender_Evaluator"
         href="#smtpAppender_Evaluator">evaluator</a></span></b></td>
         <td><code><a
@@ -1888,9 +1888,8 @@ public interface TriggeringPolicy<E> extends LifeCycle {
         </td>
       </tr>
 
-      <tr class="alt">
-        <td  valign="top"><b><span class="prop">cyclicBufferTracker</span></b>
-        </td>
+      <tr>
+        <td  valign="top"><b><span class="prop">cyclicBufferTracker</span></b></td>
         <td><a href="../xref/ch/qos/logback/core/spi/CyclicBufferTracker.html"><code>CyclicBufferTracker</code></a>
         </td>
         <td>
@@ -1906,8 +1905,7 @@ public interface TriggeringPolicy<E> extends LifeCycle {
           will keep events in a cyclic buffer of size 256. You may
           change the size with the help of the <span
           class="prop">bufferSize</span> option (see below).</p>
-        </td>
-        
+        </td>        
       </tr>
       <tr>
         <td><b><span class="prop">username</span></b></td>
@@ -1932,7 +1930,7 @@ public interface TriggeringPolicy<E> extends LifeCycle {
         parameter is set to false.
         </td> 
       </tr>
-      <tr class="alt">
+      <tr>
         <td><b><span class="prop">SSL</span></b></td>
         <td><code>boolean</code></td> <td>If this parameter is set to
         true, then this appender will open an SSL connection to the
@@ -1951,7 +1949,7 @@ public interface TriggeringPolicy<E> extends LifeCycle {
       </tr>
 
 
-      <tr class="alt">
+      <tr>
         <td><b>localhost</b></td>
         <td><code>String</code></td>
         <td>In case the hostname of the SMTP client is not properly
@@ -1966,6 +1964,22 @@ public interface TriggeringPolicy<E> extends LifeCycle {
         package.</td>
       </tr>
 
+      <tr>
+        <td><b>asynchronousSending</b></td>
+        <td><code>boolean</code></td>
+        <td>This property determines whether email transmission is
+        done asynchronously or not. By default, the <span
+        class="prop">asynchronousSending</span> property is
+        'true'. However, under certain circumstances asynchronous
+        sending may be inappropriate. For example if your application
+        uses <code>SMTPAppender</code> to send alerts in response to a
+        fatal error, and then exits, the relevant thread may not have
+        the time to send the alert email. In this case, set <span
+        class="prop">asynchronousSending</span> property to 'false'
+        for synchronous email transmission.
+        </td>
+      </tr>
+
 		</table>		
 		
 		<p>The <code>SMTPAppender</code> keeps only the last 256 logging
diff --git a/logback-site/src/site/pages/news.html b/logback-site/src/site/pages/news.html
index 9fc982e..8e48905 100644
--- a/logback-site/src/site/pages/news.html
+++ b/logback-site/src/site/pages/news.html
@@ -30,7 +30,17 @@
 
     <hr width="80%" align="center" />
 
-    <h3>4rd of May, 2012 - Release of version 1.0.3</h3>
+    <h3>May, 2012 - Release of version 1.0.4</h3>
+
+    <p><code>SMTPAppender</code> now admits the <span
+    class="prop">asynchronousSending</span> property, set to 'true' by
+    default. However, it can be set to 'false' for syncronous email
+    transmisison. This property was requested in <a
+    href="http://jira.qos.ch/browse/LBCLASSIC-323">LBCLASSIC-323</a>
+    by Patrick Houk.</p>
+
+
+    <h3>4th of May, 2012 - Release of version 1.0.3</h3>
 
     <p><code>PatternLayoutEncoder</code> class now admits the <span
     class="prop"><a

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

Summary of changes:
 .../logback/classic/issue/lbclassic232/Simple.java |   34 ------------------
 .../{lbclassic232 => lbclassic323}/Barebones.java  |    2 +-
 .../logback/classic/issue/lbclassic323/Simple.java |   34 ++++++++++++++++++
 .../logback_smtp.xml                               |    1 +
 .../ch/qos/logback/core/net/SMTPAppenderBase.java  |   25 ++++++++++++--
 logback-site/src/site/pages/mailinglist.html       |    7 ----
 logback-site/src/site/pages/manual/appenders.html  |   36 ++++++++++++++------
 logback-site/src/site/pages/news.html              |   12 ++++++-
 8 files changed, 94 insertions(+), 57 deletions(-)
 delete mode 100644 logback-classic/src/test/java/ch/qos/logback/classic/issue/lbclassic232/Simple.java
 rename logback-classic/src/test/java/ch/qos/logback/classic/issue/{lbclassic232 => lbclassic323}/Barebones.java (93%)
 create mode 100644 logback-classic/src/test/java/ch/qos/logback/classic/issue/lbclassic323/Simple.java
 rename logback-classic/src/test/java/ch/qos/logback/classic/issue/{lbclassic232 => lbclassic323}/logback_smtp.xml (90%)


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


More information about the logback-dev mailing list