[SQL printing] mybatis log framework logback does not print SQL execution logs

I was debugging SQL in the project and found that the existing configuration cannot print out SQL statements using logback. The original configuration is as follows (it is not easy to modify it to debug):

<!--jdbc -->
<logger name="java.sql.Connection" level="ERROR" />
<logger name="java.sql.PreparedStatement" level="ERROR" />
<logger name="org.apache.zookeeper" level="ERROR" />
  • After data search and testing, everything added to the configuration file of mybatis <setting name="logPrefix"/> <setting name="logImpl"/> does not work.

Later, the test added the following configuration to logback.xml and turned on Debug log output. where name="com.x.x.dao.XxxDao" is mybatis DAOthe interface package path

<logger name="com.x.x.dao.XxxDao" level="DEBUG" />

The result output is as follows, Preparing is the original sql, Parameters is the variable parameters:

==> Preparing: select order_id, order_code, org_remark, add_payment, activity_id, evaluate_score FROM tc_order WHERE 1=1 and category =? and order_status = ? and start_date <=? and third_order_id = ? 
2017-06-07 14:30:02,679 [executor-1] DEBUG com.xx.xx.dop2c.order.ext.TcOrderExtDao.queryForQueue - 47 - ==> Parameters: 253(Long), 30(Integer), 2017-06-07 14:30:02(String), 0(String)

Guess you like

Origin blog.csdn.net/bingxuesiyang/article/details/121977508