MyBatis | Output Executed SQL to the Log
When you add the logback dependency, SQL is output at the DEBUG level.
build.gradle
compile 'ch.qos.logback:logback-classic:1.1.3'
Log output
18:10:01.123 [main] DEBUG sample.mybatis.selectTest - ==> Preparing: select * from test_table where id=? and id=?
18:10:01.151 [main] DEBUG sample.mybatis.selectTest - ==> Parameters: 1(Integer), 1(Integer)
18:10:01.165 [main] DEBUG sample.mybatis.selectTest - <== Total: 1
The executed SQL and the bound parameters are output.
Because the executed SQL statement ID (sample.mybatis.selectTest) is used as the logger name, log output can be controlled by using the statement ID.