Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
958 views
in Technique[技术] by (71.8m points)

how do I turn off logging in java c3p0 connection pooling lib?

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
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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);

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...