When I use mvn tomcat7:run log4j works perfectly but when I use mvn tomcat7:deploy to run in on the tomcat on my local machine I get filenotfoundexception for the log4j.properties files. Any ideas how can I fix this?
<build>
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<!-- --> <version>2.1</version>
<configuration>
<url>http://localhost:8080/manager/text</url>
<server>localhost</server>
</configuration>
</plugin>
</plugins>
UPDATE
In log4j.properties I am using file appender to log to a file called "loging.log". This file is creatd in the tomcat/bin directory but it is empty.
Found answer from here
Had to change from
PropertyConfigurator.configure("log4j.properties");
to this
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
PropertyConfigurator.configure(classLoader.getResource("log4j.properties"));
Another solution is to hard code the path of the log4j.properties file but I dont recommend it:
PropertyConfigurator.configure("C:/User/...../log4j.properties");