I am using log4j2 but some of my dependencies use log4j. When I run the application from an executable jar file I get only a couple log lines and the following message:
log4j:WARN No appenders could be found for logger (org.reflections.Reflections).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
But when I run the application inside IntelliJ it works as expected, no warnings and all logs produced.
I have used maven enforcer to ban log4j. I also tried adding the dependency but setting the scope to "provided".
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>[0.0,1.2.17)</version>
<scope>provided</scope>
</dependency>
I also did the above with a single version number instead of a range. All of these work for when it is run in IntelliJ but none of them work when the application is run as an executable jar.
The answers to the question How do you configure logging in Hibernate 4 to use SLF4J would suggest that I am getting this error message because log4j is somehow creeping into my jar and I can't seem to keep it out.
Any advice on how to fix this would be appreciated. Thanks.
Please note that I am using log4j2 and the following dependencies
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.25</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.8.2</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.8.2</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>2.8.2</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-1.2-api</artifactId>
<version>2.8.2</version>
</dependency>