我的 logback 有两个附加程序,一个控制台和一个电子邮件附加程序,它从我的自定义扩展SMPTAppender
......我的记录器logger.error("My error");
在我的自定义 SMTPAppender 中触发了 x 分钟后发送的电子邮件,问题是,调度程序不会等待延迟,因为两个被初始化。
这发生了两次:
将名为 [EMAIL] 的附加程序附加到 Logger[ROOT]
这就是为什么 IMO 还创建了两个调度程序(start
方法被调用两次)
Logback.xml(问题应该出在哪里):
<configuration debug="true">
Logging per console and per email
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<layout class="ch.qos.logback.classic.PatternLayout">
<Pattern>
sets the format of the output
%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n
</Pattern>
</layout>
</appender>
<appender name="EMAIL" class="com.konverto.phonebillasaj.appenders.ScheduledSMTPAppender">
<subject>TESTING: %logger{20} - %m</subject>
<layout class="ch.qos.logback.classic.html.HTMLLayout" />
<smtpHost>smtp.xxx.net</smtpHost>
<smtpPort>587</smtpPort>
<STARTTLS>true</STARTTLS>
<username>xxxx@xxx.net</username>
<password>xxxx</password>
<to>xxx@xxx.net</to>
<from>xxx@xxx.net</from>
<maxMessages>10</maxMessages>
for testing , comment in production, default 256
<cyclicBufferTracker class="ch.qos.logback.core.spi.CyclicBufferTracker">
Send just one log entry per email, ready for a lot of emails if you put one.
<bufferSize>1</bufferSize>
</cyclicBufferTracker>
for testing , comment in production, default asynchronousSending = true
<asynchronousSending>false</asynchronousSending>
</appender>
<logger name="com.konverto.phonebillasaj" level="error" additivity="false">
<appender-ref ref="EMAIL"/>
<appender-ref ref="CONSOLE" />
</logger>
<root level="error">
<appender-ref ref="EMAIL" />
<appender-ref ref="CONSOLE" />
</root>