-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ERROR StatusConsoleListener Appenders contains an invalid element or attribute "MyAppender" #1386
Comments
By shading multiple JAR files into one you break many things necessary for the correct behavior of Log4j2 (multi-release to run on Java 9+, plugin caches to use components without scanning packages, etc.). For all these to work you need the <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<dependencies>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-transform-maven-shade-plugin-extensions</artifactId>
<version>0.1.0</version>
</dependency>
</dependencies>
<configuration>
<transformers>
<transformer implementation="org.apache.logging.log4j.maven.plugins.shade.transformer.Log4j2PluginCacheFileTransformer"/>
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>org.apache.logging.log4j.samples.async.Log4J2AsyncLogger</mainClass>
<manifestEntries>
<Multi-Release>true</Multi-Release>
</manifestEntries>
</transformer>
</transformers>
</configuration>
</plugin> |
@ppkarwasz thank you for the assistance! The next config worked for me:
C:\Users\Yevhen\IdeaProjects\log4j2-demo\target>java -jar log4j2-demo-1.0.0-shaded.jar
WARNING: sun.reflect.Reflection.getCallerClass is not supported. This will impact performance.
Hello world! |
Remember the |
Description
It is not possible to use custom logger appender without explicitly specifying appender's package in
log4j2.xml
.Configuration
Version:
2.20.0
Operating system:
Windows 10
,Ubuntu 20.04.5 LTS
JDK:
openjdk 17.0.6 2023-01-17 LTS
Logs
Reproduction
📄
pom.xml
📄
MyAppender.java
📄
log4j2.xml
log4j2.xml
and replace:According to this article
MyAppender
must be autoconfigured at build time:Even if I add this plugin to
pom.xml
, nothing will be changed:The text was updated successfully, but these errors were encountered: