The project is relatively large, a variety of chaotic framework. The log4j is configured with the info level.
However, I need log4j to print out the execution of SQL when I develop today.
First change the rootlogger level of log4j to debug ... The result is a variety of logs flying.
Log4j.rootLogger=DEBUG, stdout
Log4j.logger.org.apache=ERROR
#log4j.logger.org.hibernate=ERROR #Not used, blocked
Log4j.logger.org.springframework=ERROR
Log4j.logger.org.mybatis=DEBUG
Log4j.logger.org.apache.http=ERROR
Log4j.logger.com.netflix=ERROR
Log4j.appender.stdout=org.apache.log4j.ConsoleAppender
Log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%5p %d %C: %m%n
log4j mybatis Print out SQL, do not print the configuration of logs of other frames
Another way to print
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<property name="LOG_HOME" value="${catalina.base}/logs" />
<property name="PROJECT_NAME" value="dgdr" />
<property name="ENCODING" value="UTF-8" />
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50}- %msg%n</pattern>
</encoder>
</appender>
<root level="DEBUG">
<appender-ref ref="STDOUT" />
</root>
<logger name="com.github" level="INFO" />
<logger name="org" level="INFO"/>
<logger name="net" level="INFO"/>
<logger name="org.mybatis" level="DEBUG"/>
<logger name="java.sql" level="DEBUG" />
</configuration>
The log framework only prints out the configuration of MyBatis SQL