Reputation: 861
Up until recently, we created a new database connection for every query. Each query is setup using connection.prepareStatement(query) and we were able to log these queries to our logger (java.util.logging) with preparedStatement.toString(). This was using the postgresql JDBC driver.
Now we've switched to using c3p0 to manage connection pools and unfortunately preparedStatement.toString() no longer returns the prepared query statement.
I have read that c3p0 logging can be directed to the standard logging facility but unfortunately I have been unable to find where these messages are going. Where can I find these messages? Glassfish 3's console in NetBeans states that debugging is enabled.
INFO: Initializing c3p0-0.9.1.2 [built 21-May-2007 15:04:56; debug? true; trace: 10]
Upvotes: 2
Views: 2442
Reputation: 37778
I'm not sure, if c3p0's logging is what you are really looking for?
I would recommend using log4jdbc, which can log any JDBC queries (with parameters), and even provide you with a stack trace pointing to your JDBC/Hibernate/... statement, even if you're using a connection pool (use the option -Dlog4jdbc.debug.stack.prefix=com.mycompany.myapp
). It can also display timing information, and a lot more.
Upvotes: 3
Reputation: 12748
The logging seems to be on like the log says (debug?true), but if you read the box on the link you had on your post you will find the setup options that should be checked for finding the right file.
If you end up logging to the so called last resort option, it should log to System.Err
and this may cause the problem: this post tells that System.Err is not by default always visible in any log file!
So keep trying the other options on the previously mentioned box or use the fix on the answer section of the post I linked :)
Upvotes: 2