I use the maven-assembly-plugin
plugin to compile a fat jar. I have log4j2
and these dependencies in my pom.xml
:
<dependencies>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.11.0</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.11.0</version>
</dependency>
<dependency>
<groupId>com.sumologic.plugins.log4j</groupId>
<artifactId>sumologic-log4j2-appender</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.2</version>
</dependency>
</dependencies>
When I configure the logger in the log4j XML configuration file, I specify the SumoAppender and a console output appender.
When I run the main app via mvn exec:java
the SumoLogic appender works.
However when I compile a fat jar and run the app via java -jar fatjar.jar
, the SumoLogic Appender doesn't run at all, and there is no error that gets output.
I checked that the class exists in my app using Class.forName("com.sumologic.log4j.SumoLogicAppender")
and the package indeed exists.
Does anyone know what's going on?