Re: Unable to locate plugin type for Custom log4j2 Appender
"Piotr P. Karwasz" <[email protected]> Mon, 5 Aug 2024 19:14:21 +0200
| Newsgroups | gmane.comp.jakarta.log4j.user |
|---|---|
| Message-ID | <CAFmygFaidW6k8u21zJ+7wDXnqAGnJZyDNpb602KLnmNePmyLAw@mail.gmail.com> |
Hi Amanda, On Mon, 5 Aug 2024 at 17:35, Amanda Liu <[email protected]> wrote: > Thanks for your response! I am using SBT build tool, and the JDK version = is 17. And yes, I do see a `Log4jPlugins.dat` file in my JAR. I see some `l= og4j.core.appender` objects are included in this .dat file, however my new = custom appender I added is not there. You must be packaging your application as an Uber JAR / Fat JAR, so the contents of your application and all its dependencies end up in a flat JAR. Shading causes problems when multiple JARs contain the same file. When such a situation occurs, you must apply some strategy to merge these files. The files that might require merging in an application that uses Log4j 2 Core are: 1. The `META-INF/MANIFEST.MF` of the Uber JAR must contain the attribute `Multi-Release: true`, 2. The contents of all `META-INF/services/<something>` service files must be concatenated to obtain a merged `META-INF/services/<something>` file, 3. Multiple `META-INF/org/apache/logging/log4j/core/config/plugins/Log4j2Pl= ugins.dat` files must be merged together using a specific algorithm. We do publish a Maven Shade resource transformer to merge these files [1] and the same functionality is offered by a Gradle Plugin [2]. I am not aware however of any sbt plugins that do it. To solve the problem with the merging of `Log4j2Plugins.dat`, you can upgrade to version `3.x`, which uses a service file for the same purpose. Could you provide a minimal reproducible sbt example that reproduces the issue you are having? Piotr [1] https://logging.apache.org/log4j/transform/latest/#maven-shade-plugin-e= xtensions [2] https://github.com/GradleUp/shadow/blob/main/src/main/groovy/com/github= /jengelman/gradle/plugins/shadow/transformers/Log4j2PluginsCacheFileTransfo= rmer.groovy