<logger name="org.mybatis">
<level value="TRACE"/>
</logger>
<logger name="java.sql">
<level value="WARN"/>
</logger>
I used the above code snippet in my logback.xml and got the sql query in logger. If require to print sql in specific logger, use tag.
thanks, I add to logback.xml
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${logFile}</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${logFile}.%d.zip</fileNamePattern>
<maxHistory>5</maxHistory>
</rollingPolicy>
<encoder>
<pattern>[%date] [%level] %msg [%file:%line] [%logger{100}] [%thread] [AspLink-${project.version}]%n</pattern>
</encoder>
</appender>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>[AspLink-${project.version}] [%level] %msg [%file:%line] [%logger{100}]%n</pattern>
</encoder>
</appender>
<logger name="liquibase" level="INFO" />
<logger name="ru.company.asplink.dao" level="DEBUG" />
<logger name="org.mybatis">
<level value="TRACE"/>
</logger>
<root level="INFO">
<appender-ref ref="FILE" />
<appender-ref ref="STDOUT" />
</root>
You configuration of appender is correct but logger configuration is not.
To log SQL statements for particular mybatis mapper set DEBUG (TRACE to see query parameters and results) level for logger with fully qualified mapper name
<logger name="com.mycompany.myapp.mapper.MyMapper" level="DEBUG"/>
You can log all SQL statements from all mappers if they are in the same package like this
<logger name="com.mycompany.myapp.mapper" level="DEBUG"/>