I like to use log4jdbc (http://code.google.com/p/log4jdbc/) for logging DB statements within Java JDBC environment. Here is a short instruction how to set it up within a BEA/Oracle weblogic container.
1. Download log4jdbc and slf4j
2. Edit the startup script of you domain and add the following lines
set SAVE_JAVA_OPTIONS=%JAVA_OPTIONS% -Dlocal.url=t3://localhost:7001 -Dlog.dir=D:\logs %LOG4JDBC_OPTIONS%
set LOG4JDBC_OPTIONS=-Dlog4jdbc.drivers=oracle.jdbc.OracleDriver -Dlog4jdbc.sqltiming.warn.threshold=200 -Dlog4jdbc.sqltiming.error.threshold=500
3. This will register a log4jdbc driver for Oracle and the log level WARN will be used for statements longer than 200ms, as well as the ERROR level will be uses for statements which take longer than 500ms
4. You also have to add the necessary jar files to the startup classpath of your weblogic container
as you see we need a log4jdbc, slf4j-api, slf4j-log4j and a log4j jar. The version should fit together and the log4j version has to be at least 1.2.14. The rest of the classpath links to the log4j config. A sample config for log4jdbc is here http://code.google.com/p/log4jdbc/source/browse/trunk/doc/log4j.xml.
5. Last step is the setup of your jdbc configuration. To activate the log4jdbc driver you could just change your current jdbc config file or the data source within the weblogic container. Here is a sample:
Original JDBC config