I am using log4j 1.2 with commons-logging. Now I am trying to upgrade it to log4j2. But how to use log4j2 with commons-logging to initialize log4j2.
I tried to initialize commons logging in the below way. Its working fine
**Statement1**: static Log log = new Log4JLogger(Logger.getLogger(Example.class));
**Statement2**:log.debug("debug statement");
Here I am using object of type org.apache.commons.logging.Log initialized with object of org.apache.log4j.Logger
.(org.apache.log4j.Logger
is the class from log4j 1.2 where as from log4j2 is changed to org.apache.logging.log4j.Logger
)
Now after I upgrade to log4j2, Statement1 will not work as Log4JLogger()
constructor expects argument of type org.apache.log4j.Logger
type.
So, how do I use commons logging with Log4j2?