My project is set up with SpringMVC+Mybatis+EXTJS4. This is my configuration:
# Rules reminder:
# DEBUG < INFO < WARN < ERROR < FATAL
# Global logging configuration
log4j.rootLogger=DEBUG,stdout
log4j.logger.org.apache.ibatis=DEBUG,stdout
log4j.logger.java.sql=DEBUG,stdout
#log4j.additivity.com.ibatis = false
#log4j.additivity.java.sql = false
## Console output...
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%5p %d %C: %m%n
but it does not print SQL in Console,can any one help me? thanks lot
Background information. MyBatis is a persistence framework for Java that supports custom SQL statements, stored procedures, and advanced mappings. MyBatis eliminates the need to use JDBC code, manually configure parameters, and retrieve result sets.
typeHandlers. Whenever MyBatis sets a parameter on a PreparedStatement or retrieves a value from a ResultSet, a TypeHandler is used to retrieve the value in a means appropriate to the Java type.
Jaradinor's answer will probably work. But, I think the underlying issue is due to how the MyBatis LogFactory class is implemented. In a static block, it attempts to load slf4j, then commmons-logging, then log4j. So, if you have commons-logging in your classpath it will use that. Since you are using Spring, you probably do have commons-logging.
It's because of issues like this I have moved to slf4j. Use slf4j-log4j12
to have slf4j call to log4j. Use jcl-over-slf4j
to route all the Spring (and other) commons-logging to slf4j (and then to log4j). Make sure you exclude the 'real' commons-logging jar file from your classpath when you do this - maybe with an <exclude>
if you are using Maven.
I encountered a similar problem. The following code helped me (i've used it in the mybatis class configuration):
org.apache.ibatis.logging.LogFactory.useLog4JLogging();
May cause problems become other logging system in your classpath.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With