Here’s a quick and dirty tip to enable JDBC logging for Oracle thin drivers.Enabling JDBC logging for connections of a pool is straightforward with JDBC connection proxies like p6spy tool. Sadly some applications still don’t use connection pools configured on J2EE application server and connect directly to database without retrieving a connection from a pool and with the JDBC URL hardcoded. For the latters, you can still trace JDBC activity.
To do so:
-
1) Configure Weblogic server, to use the Oracle’s debug thin driver which is called ojdbc14_g.jar and its located in the $WEBLOGIC_HOME/server/ext/jdbc/oracle/ directory. Just add it in the server’s CLASSPATH the path to this library.
-
2) Put the following class in the server’s CLASSPATH to control the logging level. The default one (2) is very high it creates a huge amount of log. This class takes as first argument the log levelwhich should go from 1 (lower) to 3 (higher)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | |
-
3) Configure Weblogic to use this startup class and give the log level as an argument (1 is fineand doesn’t fill too quickly).(On the Startup & shutdown node of the adminisration console )
-
4) Enable JDBC logging for the Weblogic server in the administration console.(Server node -> Logging tab -> JDBC tab )
-
5) Restart the server
Now you should see the connection string used, the SQL (prepared)statementsand the Oracle’s session attributes in the JDBC log file.Note that enabling logging has a great impact on performance even when the logging levelis low.