Migrate from log4j1 to log4j2 using Log4j Bridge

Viewed 4431

I am starting to migrate an existing project from log4j1 to log4j2, i added the following maven dependencies

     <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j-1.2-api</artifactId>

    <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j-api</artifactId>

    <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j-core</artifactId>

I also deleted all logj1 jar like they say on the offical migration guide, i don't know if i have to replace all log4j.xml configuration files with log4j2.xml and change the configuration to the new syntax? If it's the case, how i can do with third parties that use log4j and configure it with log4j.xml ?

1 Answers

First, there can only be a single logging configuration per application. If a third party is providing a logging configuration in a jar to be included in your app that is an issue. If it is a separate third party app then I don't understand why you are porting it from Log4j 1 to Log4j 2. That should be their problem.

Yes, your dependencies are correct. As for whether to use a log4j 1 format configuration or log4j 2 I would always recommend using the log4j 2 format if you can do the work. You can certainly try to use the log4j 1 configurations by following http://logging.apache.org/log4j/2.x/manual/compatibility.html.

Related