[logback-user] SMTPAppender mail not sent (logback 1.0.0, JDK 1.5)

ceki ceki at qos.ch
Fri May 4 00:03:11 CEST 2012


On 19.04.2012 00:02, Dave wrote:
> Hi everyone. First time poster. I thought I'd share my experiences and
> findings on the SMTPAppender issues.
>
> I've been struggling to get the STMPAppender working consistently ever
> since version 0.9.29. I've noticed on this mailing list that it might
> have been related to JDK 1.5. So I've upgraded our environment to JDK
> 1.6 (along with upgrading logback to 1.0.1) and every seemed to be
> working fine.
>
> Then a few days ago, I didn't receive an e-mail from a STMPAppender
> event that I knew for sure I was supposed to get. I isolated and
> reproduced the event 10 consecutive times, with about 2 seconds between
> events. When I checked my email log, I only received 9 messages.
>
> I ran the test again, and got all 10 messages as expected. Tried again
> once more, and again got 10 messages. I decided to run my test one more
> time before I put it to rest, but this time I got 9 messages.
>
> After browsing the mailing lists for this issue, I saw Ceki's sample
> code (posted March 5) testing the ExecutorService. I clipped it out and
> tried it on my machine (running jdk1.6.0_31). I've found that this too
> was giving inconsistent results. Out of the three processes it suppose
> to execute, I get results of 3,3,1,0,0,3,3,1,3 .... I was surprised to
> see it not execute any processes at times. When running on JDK 1.5, I'm
> unable to get any results.

As you mentioned, setting ThreadPoolExecutor's corePoolSizeto 0 does not 
work in JDK 1.5. Thank you for investigating this issue. As for 
incomplete transmission under JDK 1.6, I am unable to reproduce the 
problem unless System.exit() is invoked to exit the program.

Here is the application I am using.

package ch.qos.logback.classic.issue.lbclassic232;

import ch.qos.logback.core.Context;
import ch.qos.logback.core.ContextBase;

public class Barebones {

   public static void main(String[] args) {
     Context context = new ContextBase();
     for(int i = 0; i < 3; i++) {
       SenderRunnable senderRunnable = new SenderRunnable(""+i);
       context.getExecutorService().execute(senderRunnable);
     }
     System.out.println("done");
     //System.exit(0);
   }

   static class SenderRunnable implements Runnable {
     String id;
     SenderRunnable(String id) {
       this.id = id;
     }

     public void run() {
       try {
         Thread.sleep(2000);
       } catch (InterruptedException e) {
       }
       System.out.println("SenderRunnable " +id);
     }
   }
}

Now that the problem affecting JDK 1.5 has been identified a fix on the 
way. This should fix http://jira.qos.ch/browse/LBCLASSIC-323

> Anyways, that's my 0.02 cents that I can offer on this. If there's any
> other help I can offer pleas let me know

Dave, thank you for investigating this problem. Much appreciated.

> -dave
-- 
Ceki
http://twitter.com/#!/ceki


More information about the Logback-user mailing list