2018年5月15日 | Leave a comment 问题: 如果生成环境报错,进行日志发送 解决: src/main/resources/logback-spring.xml <configuration debug="true"> <!-- logback-spring.xml --> <appender name="EMAIL" class="ch.qos.logback.classic.net.SMTPAppender"> <smtpHost>smtp.exmail.qq.com</smtpHost> <to>fanghua.t@thelook.cn</to> <!-- <to>ANOTHER_EMAIL_DESTINATION</to> additional destinations are possible --> <from>fanghua.t@thelook.cn</from> <username>fanghua.t@thelook.cn</username> <password>tlTFH0326</password> <subject>[ERROR]: %logger{20} - %m</subject> <layout class="ch.qos.logback.classic.PatternLayout"> <pattern>%date %-5level %logger{35} - %message%n</pattern> </layout> </appender> <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> <!-- encoders are by default assigned the type ch.qos.logback.classic.encoder.PatternLayoutEncoder --> <encoder> <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern> </encoder> </appender> <logger name="thelook" level="DEBUG" /> <logger name="com.thelook" level="DEBUG" /> <logger name="thelook" level="WARN" > <appender-ref ref="EMAIL" /> </logger> <logger name="com.thelook" level="WARN" > <appender-ref ref="EMAIL" /> </logger> <springProfile name="prod"> <root level="INFO"> <appender-ref ref="STDOUT" /> </root> </springProfile> <springProfile name="!prod"> <root level="INFO"> <appender-ref ref="STDOUT" /> </root> </springProfile> </configuration> 1234567891011121314151617181920212223242526272829303132333435363738394041 <configuration debug="true"> <!-- logback-spring.xml --> <appender name="EMAIL" class="ch.qos.logback.classic.net.SMTPAppender"> <smtpHost>smtp.exmail.qq.com</smtpHost> <to>fanghua.t@thelook.cn</to> <!-- <to>ANOTHER_EMAIL_DESTINATION</to> additional destinations are possible --> <from>fanghua.t@thelook.cn</from> <username>fanghua.t@thelook.cn</username> <password>tlTFH0326</password> <subject>[ERROR]: %logger{20} - %m</subject> <layout class="ch.qos.logback.classic.PatternLayout"> <pattern>%date %-5level %logger{35} - %message%n</pattern> </layout> </appender> <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> <!-- encoders are by default assigned the type ch.qos.logback.classic.encoder.PatternLayoutEncoder --> <encoder> <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern> </encoder> </appender> <logger name="thelook" level="DEBUG" /> <logger name="com.thelook" level="DEBUG" /> <logger name="thelook" level="WARN" > <appender-ref ref="EMAIL" /> </logger> <logger name="com.thelook" level="WARN" > <appender-ref ref="EMAIL" /> </logger> <springProfile name="prod"> <root level="INFO"> <appender-ref ref="STDOUT" /> </root> </springProfile> <springProfile name="!prod"> <root level="INFO"> <appender-ref ref="STDOUT" /> </root> </springProfile></configuration> 参考: https://logback.qos.ch/manual/appenders.html https://blog.csdn.net/gebitan505/article/details/70154117