mybatis query logging with log4j2.xml

3,306 views
Skip to first unread message

kalyan k

unread,
Jun 18, 2015, 9:53:22 AM6/18/15
to mybati...@googlegroups.com
I am trying to log my query requests and responses with log4j2 and have been unable to do so. My settings are as below:

mybatis-config.xml:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
<configuration>
    <settings>
        <setting name="defaultStatementTimeout" value="3"/> <!-- seconds -->
         <setting name="logImpl" value="LOG4J2"/>
    </settings>
</configuration>

log4j2.xml:

    <Logger name="org.mybatis" level="DEBUG">
<AppenderRef ref="applogfile" />
<AppenderRef ref="stdout" />
</Logger>
<Logger name="java.sql" level="DEBUG">
<AppenderRef ref="applogfile" />
<AppenderRef ref="stdout" />
</Logger>


I see a lot of messages from mybatis about the drivers and loading the mapper files etc, but I don't see debug statements of actual queries being executed.


Guy Rouillier

unread,
Jun 18, 2015, 9:31:45 PM6/18/15
to mybati...@googlegroups.com
You need to specify DEBUG on package for your mapper classes, e.g.,
 
<Logger name="com.mycompany.myproject.mappers" level="DEBUG">
 
--
Guy Rouillier
--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mybatis-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



Avast logo

This email has been checked for viruses by Avast antivirus software.
www.avast.com


Reply all
Reply to author
Forward
0 new messages