I am using Log4j in my project and trying to run my application but it seems it cannot find log4.properties file.
This is my Maven configuration:
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>log4j.properties</include>
<include>hibernate.cfg.xml</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.2.0</version>
<configuration>
<finalName>File-Name</finalName>
<archive>
<manifest>
<mainClass>my.main.class</mainClass>
</manifest>
<manifestEntries>
<Class-Path>.</Class-Path>
</manifestEntries>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<appendAssemblyId>false</appendAssemblyId>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
And this is how I am loading the log4j.properties file in my code.
PropertyConfigurator.configure("log4j.properties");
When I try to run the application I get the following error:
log4j:ERROR Could not read configuration file [log4j.properties]. java.io.FileNotFoundException: log4j.properties (No such file or directory)
The weird thing is that if I package my application with mvn package and open the jar file I can see the log4j.properties file inside. I don't understand what is wrong since I declare the resources folder in the pom file.
EDIT: I am adding the dependency I use for log4j in the project
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
log4j.properties file is inside the src/main/resources folder