[1.2.5 Java] c3p0 logging

1,729 views
Skip to first unread message

Scott Rippee

unread,
Mar 12, 2013, 4:46:47 PM3/12/13
to play-fr...@googlegroups.com
Hello,

I'm having a problem where database jdbc queries get stuck at socketRead0.  I'd like to get c3p0 debug data to help me collect more information what's going on.  I've tried putting these lines in my log4j.properties file, but I haven't been able to get any log info from c3p0:

log4j.logger.com.mchange.v2.c3p0=DEBUG
log4j.category.com.mchange=DEBUG
log4j.logger.com.mchange=DEBUG

Any suggestions?


Scott

Scott Rippee

unread,
Apr 9, 2013, 6:28:02 PM4/9/13
to play-fr...@googlegroups.com
Requires changing the code but, Touko found a way here:

avfl...@gmail.com

unread,
Apr 10, 2013, 4:23:53 AM4/10/13
to play-fr...@googlegroups.com
no code changing is required, just add this into some @OnApplicationStart job:

com.mchange.v2.log.MLog.getLogger().setLevel(MLevel.DEBUG);

touko

unread,
Apr 8, 2013, 8:02:23 AM4/8/13
to play-framework
On Mar 12, 10:46 pm, Scott Rippee <scott.rip...@gmail.com> wrote:
> I'd like to get c3p0 debug data to help me collect more information what's
> going on.  I've tried putting these lines in my log4j.properties file, but
> I haven't been able to get any log info from c3p0:
>
> log4j.logger.com.mchange.v2.c3p0=DEBUG
> log4j.category.com.mchange=DEBUG
> log4j.logger.com.mchange=DEBUG

Hi,

with brief source code looking, DBPlugin:onApplicationStart seems to
have the following just before creating c3p0 data source:

System.setProperty("com.mchange.v2.log.MLog",
"com.mchange.v2.log.FallbackMLog");

System.setProperty("com.mchange.v2.log.FallbackMLog.DEFAULT_CUTOFF_LEVEL",
"OFF");

Don't know if there's some other way to enable logging other that to
edit Play source code?

br, Touko Vainio-Kaila

Scott Rippee

unread,
Apr 10, 2013, 5:02:14 PM4/10/13
to play-fr...@googlegroups.com
Works great:

package jobs;

import play.jobs.*;
import play.Logger;
 
@OnApplicationStart
public class C3p0Logging extends Job {
    
    public void doJob() {
        Logger.info("Setting custom c3p0 log level");
        //com.mchange.v2.log.MLog.getLogger().setLevel(com.mchange.v2.log.MLevel.ALL);
        com.mchange.v2.log.log4j.Log4jMLog.getLogger().setLevel(com.mchange.v2.log.MLevel.FINEST);

    }   
}

I haven't tried it in production so I'm not sure if it'll write to the log file.

I thought setting it like the line bellow the commented line would make it look like the other Log4j output but the output looked the same as the commented out line above it.

Available log levels and other c3p0 info: http://www.mchange.com/projects/c3p0/#configuring_logging

Scott
Reply all
Reply to author
Forward
0 new messages