Details
-
Bug
-
Status: Closed
-
Blocker
-
Resolution: Duplicate
-
2.12.0
-
None
-
None
Description
I've just got a surprise that was a showstopper to me: It seems that log4j 1.2 compatibility layer demands log4j core for working well:
In our project, we are trying to use another spi that wraps around log4j 2 , so that some specific features can be enforced.
However, when I try to use log4j 1.2 compatibility layer, it fails:
Exception in thread "main" java.lang.ClassCastException: com.ibm.is.poclog4j.commonconfig.MandatoryAppendersLoggerContext incompatible with org.apache.logging.log4j.core.LoggerContext
at org.apache.log4j.Logger$PrivateManager.getContext(Logger.java:59)
at org.apache.log4j.Logger.getRootLogger(Logger.java:45)
at com.ibm.is.poclog4j.sample.SampleLogUser.main(SampleLogUser.java:9)
The issue is there: org.apache.logging.log4j.core.LoggerContext : you shouldn't count with a core-based context, or else you violate the API contract, forcing people to use a specific implementation for log4j (in this case, the default core one).
My SPI uses the spi-provided interface for LoggingContext:
import org.apache.logging.log4j.spi.LoggerContext;
public class MandatoryAppendersLoggerContext implements LoggerContext {
Attachments
Issue Links
- duplicates
-
LOG4J2-2556 log4j-1.2-api works only with core
-
- Resolved
-