idea控制台日志打印
程序员文章站
2022-06-27 07:57:19
...
logback.xml 文件
对于查看运行的SQL语句极有帮助!
配合的依赖:
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.3</version>
</dependency>
放在resources目录下的XML文件:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<property name="HOME_LOG" value="logs"/>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<layout class="ch.qos.logback.classic.PatternLayout">
<Pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</Pattern>
</layout>
</appender>
<appender name="RollingFile" class="ch.qos.logback.core.rolling.RollingFileAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>TRACE</level>
</filter> <!-- 测试部署时使用如下配置 --> <!-- 可让每天产生一个日志文件,最多 30 个,更早的删除 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${HOME_LOG}/log-%d{yyyy-MM-dd}.log</fileNamePattern>
<maxHistory>10</maxHistory>
</rollingPolicy> <!-- RollingFileAppender 一般情况下需要配置两个参数: RollingPolicy,负责滚动。TriggeringPolicy,决定是否以及何时进行滚动 TimeBasedRollingPolicy比较特殊,它同时继承了RollingPolicy和TriggerPolicy。 -->
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n</pattern>
</encoder> <!-- 正式部署时使用此配置 --> <!-- <file>${app.home}/logs/log.log</file> <append>true</append> <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy"> <fileNamePattern>${app.home}/logs/log.%i.log.zip </fileNamePattern> <minIndex>1</minIndex> <maxIndex>7</maxIndex> </rollingPolicy> <encoder> <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n </pattern> </encoder> <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy"> <maxFileSize>50MB</maxFileSize> </triggeringPolicy> -->
</appender>
<logger name="com.lanou3g" level="DEBUG"/>
<logger name="org.springframework" level="ERROR"/>
<logger name="org.mybatis.spring" level="ERROR"/>
<logger name="org.apache" level="ERROR"/>
<logger name="ch.qos.logback" level="ERROR"/>
<root level="debug">
<appender-ref ref="STDOUT"/>
<appender-ref ref="RollingFile"/>
</root>
</configuration>