<?xml version="1.0" encoding="UTF-8" ?> <configuration scan="true" scanPeriod="60 seconds" debug="false"> <contextName>logback</contextName> <property name="log.path" value="log" /> <!--输出到控制台--> <appender name="console" class="ch.qos.logback.core.ConsoleAppender"> <encoder> <pattern>%d{HH:mm:ss.SSS} %contextName [%thread] %-5level %logger{36} - %msg%n</pattern> </encoder> </appender> <!--输出到文件--> <appender name="file" class="ch.qos.logback.core.rolling.RollingFileAppender"> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> <!--D:\\log\\logback.%d{yyyy-MM-dd}.log本地磁盘绝对路径,${log.path}/logback.%d{yyyy-MM-dd}.log项目中的相对路径--> <fileNamePattern>${log.path}/logback.%d{yyyy-MM-dd}.log</fileNamePattern> </rollingPolicy> <encoder> <pattern>%d{HH:mm:ss.SSS} %contextName [%thread] %-5level %logger{36} - %msg%n</pattern> </encoder> </appender> <root level="info"> <appender-ref ref="console" /> <appender-ref ref="file" /> </root> <!-- logback为java中的包 --> <logger name="com.mico.emptyspringboot.controller"/> <!--logback.LogbackDemo:类的全路径 --> <logger name="com.mico.emptyspringboot.controller.UserController" level="WARN" additivity="false"> <appender-ref ref="console"/> </logger> </configuration>
#application.properties引入此xmllogging.config=classpath:Logback.xml
注意:要和lombok中间件配置和使用最佳
来源:https://www.cnblogs.com/BoKe-LY/p/12160763.html