I was working on upgrading log4j1.x to log4j2.x. For that I replace log4j1.x with log4j2.17.1(get both log4j-core and api) and my pom file has commons-logging with version 1.2. I had replaces log4j.properties with log4j2.properties file. After deploying changes, in EC2 instance i am getting below error.
Exception in thread "main" java.lang.ExceptionInInitializerError
Caused by: org.apache.commons.logging.LogConfigurationException: User-specified log class 'org.apache.commons.logging.impl.Log4JLogger' cannot be found or is not useable.
at org.apache.commons.logging.impl.LogFactoryImpl.discoverLogImplementation(LogFactoryImpl.java:804)
at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:541)
at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:292)
at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:269)
at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:655)
Pom file:
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.17.1</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.17.1</version>
</dependency>
I do have commons-logging.properties file which has code below.
org.apache.commons.logging.Log = org.apache.commons.logging.impl.Log4JLogger
In my project, they have used logger as mentioned below:
A.java
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
public class A{
public static Log logger = LogFactory.get(A.class);
}
Can someone please help me out with this.