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 I put in log4j, set up a log4j.properties file. and no sql.
here is the log4j.properties file:
log4j.appender.stdout=org.apache.log4j.ConsoleAppe nder
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.Patt ernLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ ABSOLUTE} %5p %c{1}:%L - %m%n
log4j.rootLogger=debug, stdout
log4j.category.org.springframework.jdbc.core=DEBUG
here is the output for some really simple insert sql via spring jdbc: http://pastie.org/713189
Try setting these additional log4j loggers.  The first will spit out the SQL that passes through spring's JdbcTemplate, the second gives you parameter values that Spring sets on prepared statements.
<logger name="org.springframework.jdbc.core.JdbcTemplate">
  <level value="debug" />
</logger>
<logger name="org.springframework.jdbc.core.StatementCreatorUtils">
  <level value="debug" />
</logger>
Clearly this is only going to work if you're directly or indirectly executing SQL using JdbcTemplate.
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