Uploaded image for project: 'logback'
  1. logback
  2. LOGBACK-1067

The SMTPAppender's cyclicBufferTracker bufferSize param does't work

    XMLWordPrintable

Details

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • None
    • 1.1.3
    • logback-classic
    • None

    Description

      I configured an SMTPAppender with bufferSize of 2:

      	<appender name="EMAIL" class="ch.qos.logback.classic.net.SMTPAppender">
      	      <Subject>TESTING: %logger{20} - %m</Subject>
      
                     <SMTPHost>${smtpHost}</SMTPHost>
                     <To>${to}</To>
                     <From>${from}</From>
      		<charsetEncoding>utf-8</charsetEncoding>
      		<includeCallerData>true</includeCallerData>
        
      		<layout class="ch.qos.logback.classic.PatternLayout">
      			<pattern>%d{yyyy-MM-dd HH:mm:ss} %-5level \(%F:%L\) %method\(\) - %m%n</pattern>
      		</layout>
      
      		<cyclicBufferTracker class="ch.qos.logback.core.spi.CyclicBufferTracker">
      			<bufferSize>2</bufferSize>
      		</cyclicBufferTracker>
      	</appender>
      

      But when I run this program to send 3 events:

      public class HelloWorldTest {
      
          private static final Logger log = LoggerFactory.getLogger(HelloWorldTest.class);
      
          @Test
          public void testHelloWorldTest() throws InterruptedException {
              for (int i = 0; i < 3; ++i) {
                  log.error("hello world");
              }
              Thread.sleep(TimeInterval.SECONDS_PER_MINUTE * 1000);
          }
      }
      

      I get 3 emails, each showing individual events:

      2015-04-26 23:38:56 ERROR (HelloWorldTest.java:40) testHelloWorldTest() - hello world
      

      when I was expecting two emails, where the first one shows the first 2 events:

      2015-04-26 23:38:56 ERROR (HelloWorldTest.java:40) testHelloWorldTest() - hello world
      2015-04-26 23:38:56 ERROR (HelloWorldTest.java:40) testHelloWorldTest() - hello world
      

      and the second one shows last event:

      2015-04-26 23:38:56 ERROR (HelloWorldTest.java:40) testHelloWorldTest() - hello world
      

      Attachments

        Activity

          People

            logback-dev Logback dev list
            feilong feitianbenyue
            Votes:
            1 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated: