jmonroe
jmonroe

Reputation: 41

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>

Upvotes: 4

Views: 2009

Answers (2)

Enrico Scantamburlo
Enrico Scantamburlo

Reputation: 99

I had a similar problem. I just copied the java files from the old version, in my case it was FileAppender .

Upvotes: 0

rgoers
rgoers

Reputation: 9141

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.

Upvotes: 1

Related Questions