Montag, 1. Februar 2010

Log4jdbc Configuration for WebLogic

I like to use 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

set SAVE_CLASSPATH=%CLASSPATH%;%LOG4JDBC_HOME%\log4jdbc3-1.1.jar;%LOG4JDBC_HOME%\slf4j-api-1.5.0.jar;%LOG4JDBC_HOME%\slf4j-log4j12-1.5.0.jar;%LOG4JDBC_HOME%\log4j-1.2.14.jar;%LOG4JDBC_HOME%\log4j.xml;%LOG4JDBC_HOME%\kdm_conf

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

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

log4jdbc config


Thats it.


  1. Great post, excellent blog I love your writing style.

    how to ollie

  2. If you wish to enable loggers, you need to configure them in the "" file of the JVM, or another file defined in the "java.util.logging.config.file" system property, in the following way :