suman shil
suman shil

Reputation: 41

How to redirect c3p0 log messages to my application log file

I have a standalone java application. I have decided to use c3p0 for connection pooling. Currently I am using java.util.logging.Logger for logging application messages. jdk1.6 is being used. All the application log messages are being written to a file /tmp/app.log. How do I make sure that c3p0 also logs it's messages to that file. I have tried adding the following in c3p0.properties.

com.mchange.v2.log.MLog=java.util.logging.Logger

But If I run the application I see the following message and app.log does not contain any c3p0 log.

Tried without success to load the following MLog classes: java.util.logging.Logger Nov 11, 2011 2:12:23 PM com.mchange.v2.log.MLog INFO: MLog clients using java 1.4+ standard logging.

Upvotes: 1

Views: 2287

Answers (1)

Gordon
Gordon

Reputation: 1914

If you use log4j-over-slf4j, MLog will log to that "fake" log4j, which will in turn be slf4j, then you can use slf4j-jdk14 so that slf4j sends logs to java.util.logging.

EDIT: Didn't realize I had answered two questions about this. The other one was updated about a year after I answered it, as JBoss decided to add some utterly stupid crap into their logger. See answer 14932944 to question 6852916. Basically, you need to create an empty class "org.apache.log4j.Hierarchy" to override the dumbness, and then you can go back to happily using SLF4J.

Upvotes: 2

Related Questions