I have some tests that I run with SpringJUnit4ClassRunner. I also just migrated to Log4j2 and now I have trouble loading my log4j2.xml configuration file, I always get this error:
ERROR StatusLogger No log4j2 configuration file found. Using default
configuration: logging only errors to the console.
The problem is that the configuration file is not on the classpath. Instead I keep it in a separate folder together with other configuration data outside of the classpath. When I start the test I already set -Dconfig=/path/to/config/folder. I know I can also pass -Dlog4j.configurationFile=... when I run the tests, but I do not want to do that.
What I want to do is use Spring annotation based configuration to write a configuration class in which I programatically set the location for Log4j. This is possible if I have a web application, but I don't know how to apply this to SpringJUnit4ClassRunner.
@Configuration
public class Log4jConfiguration {
/** Initialize Log4j2 with a custom location for the log4j2.xml **/
}