下面是我在 Spring Boot 项目中的 logback.xml。cyclicBufferTracker 似乎没有。当生成 5 条错误日志消息时,我需要触发 1 封电子邮件。但目前我收到 5 封不同的电子邮件。如何每 5 条错误日志消息收到 1 封电子邮件
<configuration>
<appender name="out" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<appender name="emailAppenderGmail" class="ch.qos.logback.classic.net.SMTPAppender">
<smtpHost>smtp.gmail.com</smtpHost>
<smtpPort>587</smtpPort>
<STARTTLS>true</STARTTLS>
\ <username>myid@gmail.com</username>
<password>password</password>
<to>myid@gmail.com</to>
<from>myid@gmail.com</from>
<subject>Error Log</subject>
<layout class="ch.qos.logback.classic.html.HTMLLayout"/>
<cyclicBufferTracker class="ch.qos.logback.core.spi.CyclicBufferTracker">
<!-- only 3 log entries on email -->
<bufferSize>3</bufferSize>
</cyclicBufferTracker>
</appender>
<root level="error">
<appender-ref ref="emailAppenderGmail"/>
<appender-ref ref="out"/>
</root>
</configuration>