I am running my app with Maven. But I get an error:
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
App uses log4j:
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class App {
public static void main(String[] args) {
Logger logger = LoggerFactory.getLogger(App.class);
logger.info("Test 1,2,3");
System.out.println("End of my program");
}
}
pom.xml file includes next dependencies:
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.30</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.30</version>
<scope>test</scope>
</dependency>
How to solve this problem? I checked solutions in google but it doesnt help...
I tried to add implepentation for example slf4j-simple but nothing changed
CodePudding user response:
The solution did not need to test scope in Slf4j Dependencies because it is probably not available when you run your main method.
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.30</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.30</version>
<scope>test</scope> //Remove the test scope
</dependency>
Then it's working fine without any errors.
Thanks.