这是一个包含我的 Logback 的片段SMTPAppender
:
<appender name="logManager-smtpAppender" class="ch.qos.logback.classic.net.SMTPAppender">
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>WARN</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>NEUTRAL</onMismatch>
</filter>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>ERROR</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
<asynchronousSending>false</asynchronousSending>
<smtpHost>my.smtp.host</smtpHost>
<to>john.smith@example.com</to>
<from>no-reply@example.com</from>
<username>my_smtp_user</username>
<password>my_smtp_password</password>
<subject>%logger{20} - %m</subject>
<layout class="ch.qos.logback.classic.html.HTMLLayout"/>
<cyclicBufferTracker class="ch.qos.logback.core.spi.CyclicBufferTracker">
<bufferSize>1</bufferSize>
</cyclicBufferTracker>
</appender>
当以下 Java 执行时:
logger.warn("This is a warning.");
logger.error("This is an error.");
我只收到 1 封电子邮件。通过设置bufferSize
为 1,我预计会收到 2 封不同的电子邮件,每封电子邮件中都有 1 条日志消息。这是怎么回事?