Unable to locate c3p0 logging messages
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.
IN开发者_如何学编程FO: Initializing c3p0-0.9.1.2 [built 21-May-2007 15:04:56; debug? true; trace: 10]
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.
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 :)
精彩评论