我的spring-boot应用程序中有以下logback.xml
:
<?xml version="1.0" encoding="UTF-8" ?>
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
...
</appender>
<timestamp key="datetime" datePattern="yy-MM-dd-HH-mm-ss" />
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
...
</appender>
<appender name="EMAIL" class="ch.qos.logback.classic.net.SMTPAppender">
<smtpHost>smtp.gmail.com</smtpHost>
<smtpPort>587</smtpPort>
<STARTTLS>true</STARTTLS>
<username></username>
<password></password>
<to>admin@gmail.com</to>
<from>dev@gmail.com</from>
<subject>Error</subject>
<layout class="ch.qos.logback.classic.html.HTMLLayout"/>
<asynchronousSending>true</asynchronousSending>
<encoder>
<pattern>
%d{dd.MM.yy HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
</pattern>
</encoder>
</appender>
<root level="INFO">
<appender-ref ref="STDOUT" />
<appender-ref ref="FILE" />
<appender-ref ref="EMAIL" />
</root>
</configuration>
上下文没有错误:
java.lang.IllegalStateException: Logback configuration error detected:
ERROR in ch.qos.logback.core.joran.action.AppenderAction - Could not create an Appender of type [ch.qos.logback.classic.net.SMTPAppender]. ch.qos.logback.core.util.DynamicClassLoadingException: Failed to instantiate type ch.qos.logback.classic.net.SMTPAppender
ERROR in ch.qos.logback.core.joran.spi.Interpreter@22:73 - ActionException in Action for tag [appender] ch.qos.logback.core.joran.spi.ActionException: ch.qos.logback.core.util.DynamicClassLoadingException: Failed to instantiate type ch.qos.logback.classic.net.SMTPAppender
ERROR in ch.qos.logback.core.joran.action.AppenderRefAction - Could not find an appender named [EMAIL]. Did you define it below instead of above in the configuration file?
ERROR in ch.qos.logback.core.joran.action.AppenderRefAction - See http://logback.qos.ch/codes.html#appender_order for more details.
...
我错了什么?
答案 0 :(得分:5)
compile ('javax.activation:activation:1.1.1')
compile ('javax.mail:mail:1.4.7')
依赖关系帮助我