4

We are using mybatis 3, I am want to see the SQL logs but couldn't find how to enable it. I am using log4j in my application. I followed this mybatis documentation - http://mybatis.github.io/mybatis-3/logging.html , but when I run the application I get the below exception. Am I missing something,

Cause: org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: org.apache.ibatis.builder.BuilderException: The setting logImpl is not known. Make sure you spelled it correctly (case sensitive).

Have given this setting in mybatis configuration file under configuration

<settings>
 <setting name="logImpl" value="LOG4J"/>
</settings>
2
  • this BuilderException is gone after updating the mybatis version from 3.0.3 to 3.2.2. But where to check the logs, I am using File appender in log4j properties, but there are no logs formed in the log file that I have used for file appender. My mybatis configuration has the setting like this <settings> <setting name="logImpl" value="LOG4J"/> </settings> And this is my log4j properties log4j.rootLogger=TRACE, file log4j.logger.RawMaterialSupplier=TRACE log4j.appender.file=org.apache.log4j.RollingFileAppender log4j.appender.file.File=C:\\loging.log ...... ...... Commented Apr 19, 2013 at 9:15
  • Anybody has some suggestions, I am still not able to do this. Commented May 6, 2013 at 6:11

1 Answer 1

1

My situation was the same: I was using mybatis 3.1, and received same error. Is seems like logImpl property was added in later versions (3.2). Experimentally I've found out, that mybatis was trying to use slf4j for logging, while I want to use log4j.

For me the fix was to add dependency on slf4j-log4j bridge library( I'm using: log4j 1.2.17, slf4j-log4j12 1.7.5). So, the workaround is not to set logger for mybatis, but to set another implementation for default logging interface (slf4j-api).

Sign up to request clarification or add additional context in comments.

2 Comments

so how to add the configuration?
we had maven project, so I've just added slf4j-log4j as a dependency in my pom.xml. On build time it's placed into war which is deployed on WAS

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.