c3p0
c3p0 copied to clipboard
Log4j2 doesn't work
Hi there, I found that the log4j2 doesn't work.
Here's the console output: com.mchange.v2.log.MLog 'com.mchange.v2.log.log4j.Log4jMLog' could not be loaded! java.lang.ClassNotFoundException: org.apache.log4j.Logger
My log4j version is 2.10.0, which logger class is changed to org.apache.logging.log4j.Logger
As a workaround, you can add the adapter jar https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-1.2-api
Hi, how to configure c3p0 to use log4j2? If I call System.setProperty ("com.mchange.v2.log.MLog", "com.mchange.v2.log.log4j.Log4jMLog") then log4j is used
Hi, to use Log4j2 you need to use either com.mchange.v2.log.log4j2.Log4j2MLog or log4j2 as value for the com.mchange.v2.log.MLog system property. But please note that this is only supported in mchange-commons version 2.15 (see Installation section in documentation) and that the Maven pom for version 0.9.5.2 of c3p0 only references 0.2.11. So if you're using Maven to create you lib add the 0.2.15 as an direct dependency.
Thanks for addressing this @sfieten!
Using new-ish version of c3p0
com.mchange.v2.log.MLog=log4j2
should take care of this.
See https://www.mchange.com/projects/c3p0/#configuring_logging