I try to load a configuration for log4j using the PropertyConfigurator.configure("log4j.properties")
method but I keep running into java.io.FileNotFoundException
.
I followed this question and placed my log4j.properties
file into the resources
folder.
I Also edited my pom.xml like this :
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<targetPath>${project.build.directory}</targetPath>
<includes>
<include>log4j.properties</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>src.Main</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
So when I run mvn package
the target folder generated contains my .jar and my log4j.properties side by side but when I run my jar I get the file not found exception.
How can I fix this issue ?