how to configure log4j for Mybatis to print my SQL

前端 未结 3 1929
有刺的猬
有刺的猬 2021-02-05 12:24

My project is set up with SpringMVC+Mybatis+EXTJS4. This is my configuration:

# Rules reminder:
# DEBUG < INFO < WARN < ERROR < FATAL

# Global loggi         


        
3条回答
  •  北荒
    北荒 (楼主)
    2021-02-05 12:49

    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 if you are using Maven.

提交回复
热议问题