idea
idea
打开安装插件页面
找到插件目录
选择插件包
安装的插件
点击ok按键,会重启idea
在idea顶部菜单Tools ,点击如图所示
点击后,在底部会出现打印sql的按钮
打印sql如下
注意这里的日志级别
日志文件
<?xml version="1.0" encoding="UTF-8"?>
<configuration debug="false" scan="false">
<!--自定义颜色配置-->
<conversionRule conversionWord="logbackColorFul" converterClass="cn.isite90.common.tools.util.LogbackColorFul"/>
<springProperty scop="context" name="spring.application.name" source="spring.application.name" defaultValue="logs"/>
<property name="log.path" value="logs/${spring.application.name}"/>
<!-- Console log output -->
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符-->
<pattern>%green(控制台 -) %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %highlight(%-5level) %cyan(%logger{50}) - %logbackColorFul(%msg) %n</pattern>
</encoder>
</appender>
<!-- Log file debug output -->
<appender name="debug" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/debug.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${log.path}/%d{yyyy-MM}/debug.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
<maxFileSize>50MB</maxFileSize>
<maxHistory>30</maxHistory>
</rollingPolicy>
<encoder>
<pattern>%green(控制台 -) %green%date [%thread] %-5level [%logger{50}] %file:%line - %logbackColorFul%msg%n</pattern>
</encoder>
</appender>
<!-- Log ferrorsrror output -->
<appender name="error" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/error.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${log.path}/%d{yyyy-MM}/error.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
<maxFileSize>50MB</maxFileSize>
<maxHistory>30</maxHistory>
</rollingPolicy>
<encoder>
<pattern>%green(控制台 -) %date [%thread] %-5level [%logger{50}] %file:%line - %logbackColorFul%msg%n</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>ERROR</level>
</filter>
</appender>
<!--开发环境:打印控制台-->
<springProfile name="dev">
<logger name="cn.isite90" level="debug"/>
<logger name="java.sql.Connection" level="debug"/>
<logger name="java.sql.Statement" level="debug"/>
<logger name="java.sql.PreparedStatement" level="debug"/>
<logger name="com.alibaba.nacos.client.naming" level="off" />
</springProfile>
<!--测试环境:打印控制台-->
<springProfile name="local">
<logger name="cn.isite90" level="console"/>
<logger name="java.sql.Connection" level="debug"/>
<logger name="java.sql.Statement" level="debug"/>
<logger name="java.sql.PreparedStatement" level="debug"/>
<logger name="com.alibaba.nacos.client.naming" level="off" />
</springProfile>
<!--测试环境:打印控制台-->
<springProfile name="pro">
<logger name="cn.isite90" level="error"/>
<logger name="java.sql.Connection" level="debug"/>
<logger name="java.sql.Statement" level="debug"/>
<logger name="java.sql.PreparedStatement" level="debug"/>
<logger name="com.alibaba.nacos.client.naming" level="off" />
</springProfile>
<!-- Level: FATAL 0 ERROR 3 WARN 4 INFO 6 DEBUG 7 -->
<root level="ERROR">
<appender-ref ref="console"/>
<appender-ref ref="debug"/>
<appender-ref ref="error"/>
</root>
</configuration>
打印日志插件包下载地址
链接:https://pan.baidu.com/s/1RW0BkBdReGxnvm7qkqd-Og
提取码:ki5c