1、创建logback-spring.xml配置文件
文件内容为:
<?xml version="1.0" encoding="UTF-8"?> <configuration debug="true"> <contextName>M2</contextName> <!-- <springProfile name="dev"> --> <!-- <property name="LOG_PATH" value="D:\\tsmlogs\\"/> --> <!-- </springProfile> --> <!-- <springProfile name="prod"> --> <!-- <property name="LOG_PATH" value="/data/log/" /> --> <!-- </springProfile> --> <appender name="console" class="ch.qos.logback.core.ConsoleAppender"> <filter class="ch.qos.logback.classic.filter.ThresholdFilter"> <level>DEBUG</level> </filter> <encoder> <pattern>%date %-5level [%thread] [%c:%L] - %msg%n</pattern> </encoder> </appender> <appender name="file" class="ch.qos.logback.core.rolling.RollingFileAppender"> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> <fileNamePattern>logs/log_s4tvip_%d{yyyy-MM-dd}.%i.log</fileNamePattern> <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> <maxFileSize>10MB</maxFileSize> </timeBasedFileNamingAndTriggeringPolicy> </rollingPolicy> <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder"> <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50}-%msg%n</pattern> <charset>UTF-8</charset> </encoder> </appender> <root> <appender-ref ref="console" /> <appender-ref ref="file" /> </root> </configuration>
2、配置日志文件(application-logging.yml):
logging:
path: D:\\tsmlogs\\
level:
root: INFO
org.springframework.boot: info
org.springframework.boot.autoconfigure: 'OFF'
java.sql.PreparedStatement: DEBUG
java.sql.ResultSet: DEBUG
com.panchan.m2: DEBUG
filter:
contenttypes:
level: DEBUG
encoding: UTF-8
exceptingheaders:
ignorepaths:
urlpatterns: /*
enabled: true