hey all, I'm just getting started with c3p0 for database connection pooling. It's attaching itself to my log4j output currently. How do I set logging off or at least to SEVERE level only for c3p0? I tried tweaking the properties file but not sure it's being picked up properly.
any ideas on how best to turn it off?
thanks
UPDATE: this seems to work in the log4j.properties file
log4j.logger.com.mchange.v2.c3p0.impl=INFO log4j.logger.com.mchange=INFO
c3p0 is a Java library that provides a convenient way for managing database connections. In short, it achieves this by creating a pool of connections. It also effectively handles the cleanup of Statements and ResultSets after use.
Opening a connection to a database is generally much more expensive than executing an SQL statement. A connection pool is used to minimize the number of connections opened between application and database. It serves as a librarian, checking out connections to application code as needed.
For those who are NOT using a configuration file, just to add the following in the code, before loading the connection pool.
Properties p = new Properties(System.getProperties()); p.put("com.mchange.v2.log.MLog", "com.mchange.v2.log.FallbackMLog"); p.put("com.mchange.v2.log.FallbackMLog.DEFAULT_CUTOFF_LEVEL", "OFF"); // Off or any other level System.setProperties(p);
If you use a log4j.xml file you can simple define a logger for the c3po package:
<logger name="com.mchange.v2.c3p0"> <level value="SEVERE"/> </logger>
There are analogous methods for log4j.properties. I think it's just:
log4j.logger.com.mchange.v2.c3p0=SEVERE
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With