c3p0 icon indicating copy to clipboard operation
c3p0 copied to clipboard

Log4j2 doesn't work

Open renoseven opened this issue 7 years ago • 3 comments

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

renoseven avatar Jan 25 '18 21:01 renoseven

As a workaround, you can add the adapter jar https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-1.2-api

missedone avatar Jan 25 '18 23:01 missedone

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

KorSV avatar Nov 23 '18 09:11 KorSV

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.

sfieten avatar Mar 08 '19 12:03 sfieten

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

swaldman avatar Feb 18 '24 06:02 swaldman