Spring JDBC is not logging SQL with log4j

后端 未结 6 1827
慢半拍i
慢半拍i 2020-12-11 20:06

I\'m researching spring for a possible switch to a spring stack. One of the things that I thought was cool was the ability for spring jdbc to log all the executed sql. So

6条回答
  •  攒了一身酷
    2020-12-11 20:45

    Are you sure this is the log4.properties that your application is picking up? I copied the log4j.properties you posted into a Spring application on my local machine, and I got a ton of Spring debug entries in addition to the JDBC logging. I don't see debug entries like that in your output.

    A few probable culprits for your log4j.properties not getting read correctly are:

    • log4j.properties isn't on your classpath. You can trying doing a class.getResource() on it to see if it's finding it at all.
    • There's another log4j.properties on your classpath.
    • Something is making commons-logging choose to use a different logger. You can find instructions for turning on the commons-logging diagnositics here

提交回复
热议问题