In my project i have
<bean id="ABCSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="ABCDataSource" />
<property name="mapperLocations">
<list>
<value>classpath:com/myco/dao/XYZMapper.xml</value>
</list>
</property>
<bean>
and
log4j.logger.java.sql.Connection=debug, stdout, abclog
log4j.logger.java.sql.PreparedStatement=debug, stdout, abclog
log4j.logger.java.sql=debug, stdout, abclog
log4j.logger.org.mybatis=debug, stdout, abclog
log4j.logger.org.apache.ibatis=debug, stdout, abclog
I dont see the SQL queries when i run the applicartion in log Wanted to know what am i missing
saw this post how to configure log4j for Mybatis to print my SQL suggesting to change mybatis class configuration but not sure how to do with spring SqlSessionFactoryBean
Another shortcut is to set the debug level of your mybatis mappers to true in your application.properties file:
Example log printed in console or your log file:
Try to add all the necessary lines to your configuration.
Here is the sample that should work:
You can add logging for Mybatis via it's mybatis-config.xml.
Add log4j like so:
mybatis-config.xml
Then in your log4j.properties, add the class that you'd like to log:
SQL statements are logged at the DEBUG level, so set output to DEBUG:
For more details, see the documentation.
Test with the simplest way configuration and see in the log. Then customize the output (e.g. the files, levels).
Quoting from an answer of how to configure logback for Mybatis to print my SQL, I'm not sure if this will work for you in entirety. It provides the Spring config for logging. This approach worked for me.
Give it a go, if the problem is still there. Good luck!