Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

log4j 2 migration bridge log4j-1.2-api.jar missing classes

I'm upgrading the version of log4j in our application from log4j 1.2.16 to log4j 2.5. We have many dependencies, so I'm using the log4j 1.x bridge (log4j-1.2-api.jar) that is described in the migration documentation. It describes replacing the old log4j-1.2.16.jar with log4j-1.2-api.jar. Now, however, when a specific dependency is referenced at application start up, I'm getting this message:

java.lang.ClassNotFoundException: org.apache.log4j.SimpleLayout

I see this class in the log4j-1.2.16.jar but not in log4j-1.2-api.jar.

How would I resolve this problem? Here is a portion of my pom for reference:

    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-log4j12</artifactId>
        <version>1.6.1</version>
        <exclusions>
            <exclusion>
                <artifactId>log4j</artifactId>
                <groupId>log4j</groupId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-slf4j-impl</artifactId>
        <version>2.5</version>
    </dependency>
    <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-api</artifactId>
        <version>2.5</version>
    </dependency>
    <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-web</artifactId>
        <version>2.5</version>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-core</artifactId>
        <version>2.5</version>
    </dependency>
    <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-1.2-api</artifactId>
        <version>2.5</version>
    </dependency>
like image 237
jmonroe Avatar asked Jan 18 '26 18:01

jmonroe


1 Answers

Can you post the stack trace? Something is referring to a Log4j 1.x specific Layout that won't work in Log4j 2. More than likely something is modifying the logging configuration programmatically. That code will have to be converted to use Log4j 2 configuration and/or APIs.

like image 81
rgoers Avatar answered Jan 21 '26 08:01

rgoers



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!