log4j2 ERROR StatusLogger Unrecognized conversion specifier

If a dependency contains log4j2 plugin, a Log4j2Plugins.dat cache file is included in the jar. When the Maven shade plugin is used to merge multiple jars with a Log4j2Plugins.dat file, only one will survive. Without the plugin definitions, errors are shown on startup. Log4j2 issue

One solution for this is excluding Log4j2Plugins.dat cache file from shaded jar so that Log4j scans for plugins on startup. For this, add a filter in maven-shade-plugin configuration in your pom:

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-shade-plugin</artifactId>
        <version>3.1.0</version>
        <configuration>
            <createDependencyReducedPom>false</createDependencyReducedPom>
            <filters>
                <filter>
                    <artifact>*:*</artifact>
                    <excludes>
                        <exclude>**/Log4j2Plugins.dat</exclude>
                    </excludes>
                </filter>
            </filters>
        </configuration>
        ...
    </plugin>

Another solution is to merge the cache files using a transformation plugin which is log4j version specific.

Leave a Comment

tech