Log4jdbc PreparedStatement.toString ()

I am trying to get an SQL statement after including variables using the log4jdbc framework. While he catches and prints the necessary information, but also some things that I do not need:

11.06.2011 10:49:40 net.sf.log4jdbc.Slf4jSpyLogDelegator connectionOpened
INFO: 1. Connection opened
11.06.2011 10:49:40 net.sf.log4jdbc.Slf4jSpyLogDelegator methodReturned
INFO: 1. Connection.new Connection returned 
11.06.2011 10:49:40 net.sf.log4jdbc.Slf4jSpyLogDelegator methodReturned
INFO: 1. PreparedStatement.new PreparedStatement returned 
11.06.2011 10:49:40 net.sf.log4jdbc.Slf4jSpyLogDelegator methodReturned
INFO: 1. Connection.prepareStatement(INSERT INTO `xxx` (`y`, `y`, `y`, `y`, `y`, `y`) VALUES (NOW(), ?, ?, ?, ?, ?, ?) ) returned net.sf.log4jdbc.PreparedStatementSpy@13043d2
11.06.2011 10:49:40 net.sf.log4jdbc.Slf4jSpyLogDelegator methodReturned
INFO: 1. PreparedStatement.setInt(1, 0) returned 
11.06.2011 10:49:40 net.sf.log4jdbc.Slf4jSpyLogDelegator methodReturned
INFO: 1. PreparedStatement.setInt(2, 2) returned 
11.06.2011 10:49:40 net.sf.log4jdbc.Slf4jSpyLogDelegator methodReturned
INFO: 1. PreparedStatement.setLong(3, 1426656) returned 
11.06.2011 10:49:40 net.sf.log4jdbc.Slf4jSpyLogDelegator methodReturned
INFO: 1. PreparedStatement.setLong(4, 5177344) returned 
11.06.2011 10:49:40 net.sf.log4jdbc.Slf4jSpyLogDelegator methodReturned
INFO: 1. PreparedStatement.setInt(5, 12) returned 
11.06.2011 10:49:40 net.sf.log4jdbc.Slf4jSpyLogDelegator methodReturned
INFO: 1. PreparedStatement.setInt(6, 1) returned
2011-06-11 10:49:40,993;net.sf.log4jdbc.PreparedStatementSpy@13043d2;
11.06.2011 10:49:40 net.sf.log4jdbc.Slf4jSpyLogDelegator sqlOccured
INFO: INSERT INTO `xxx` (`y`, y`, `y`, `y`, `y`, `y`, `y`) VALUES (NOW(), 0, 2, 1426656, 5177344, 12, 1) 

How can I filter records and show only the actual, last record?

+3
source share
1 answer

Looking through the sources of log4jdbc, I could conclude that all logging is done by slf4j and is delegated to the actual login implementation used by your application.

, . ( ). , log4j, java.util.logging.

, , jdbc.sqlonly; , log4jdbc, . log4j , ( log4j, log4jdbc), :

! Log only the SQL that is executed.
log4j.logger.jdbc.sqlonly=DEBUG,sql
log4j.additivity.jdbc.sqlonly=false

, java.util.logging.

+3

All Articles