<?xml version="1.0" encoding="UTF-8" ?> <configuration> <!-- 日志存放的路径 ,默认为tomcat下面的logs --> <property name="USER_HOME" value="${catalina.base}" /> <!-- 输出到窗口 --> <appender name="stdout" class="ch.qos.logback.core.ConsoleAppender"> <encoder> <pattern>%date{HH:mm:ss.SSS} %-5level %logger{40} - %msg%n</pattern> </encoder> </appender> <!-- 输出到文件 --> <appender name="logfile" class="ch.qos.logback.core.rolling.RollingFileAppender"> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> <!-- 按天分文件夹存放 ,并压缩 --> <fileNamePattern>${USER_HOME}/logs/authority/%d{yyyy-MM-dd}/log.%i.txt</fileNamePattern> <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> <!-- 每个文件的最大值 5MB,超过则编号,生成新文件 --> <maxFileSize>2MB</maxFileSize> </timeBasedFileNamingAndTriggeringPolicy> <!-- 例如,假设每天滚动,且 maxHistory 是 6,则只 保留最近 6 天的归档文件,删除之前的文件。 --> <maxHistory>60</maxHistory> </rollingPolicy> <encoder> <pattern>%date{HH:mm:ss.SSS} %-5level %logger{40} - %msg%n</pattern> </encoder> </appender> <logger name="java.sql.Connection" level="debug" /> <logger name="java.sql.ResultSet" level="debug" /> <logger name="java.sql.Statement" level="debug" /> <logger name="java.sql.PreparedStatement" level="debug" /> <logger name="org.springframework" level="debug"></logger> <logger name="org.apache.ibatis.io" level="debug"></logger> <logger name="org.mybatis.spring.SqlSessionUtils" level="debug"></logger> <logger name="cn.edu.hbcf" level="debug" /> <root level="debug"> <appender-ref ref="stdout" /> <appender-ref ref="logfile" /> </root> </configuration>