我正在尝试启用我的SLF4J记录器,但获取以下控制台消息:
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.
即使我已经将这两个依赖项添加到我的pom.xml中,但仍然有相同的消息:
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.5</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.5</version>
</dependency>
我正在测试我的记录器
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
...
//Logger
private static final Logger logger = LoggerFactory.getLogger(Hello.class);
...
logger.info("Test - - - Log message...");
我是Spring / Maven的新手,并认为这很容易解决,但没有成功......
编辑: 这是我的Maven pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.myfakecompany.project</groupId>
<artifactId>SpringApp</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>Spring MVC Webapp</name>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>4.2.3.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-cassandra</artifactId>
<version>1.4.5.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>4.3.3.RELEASE</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.5</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.5</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>spring-milestone</id>
<name>Spring Maven MILESTONE Repository</name>
<url>http://repo.spring.io/libs-milestone</url>
</repository>
</repositories>
<build>
<finalName>SpringMVCApp</finalName>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<path>/</path>
<contextReloadable>true</contextReloadable>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
编辑2: @Ceki,这里是mvn依赖:树输出......
[INFO] com.myfakecompany.project:SpringApp:war:1.0-SNAPSHOT
[INFO] +- junit:junit:jar:3.8.1:test
[INFO] +- org.springframework:spring-webmvc:jar:4.2.3.RELEASE:compile
[INFO] | +- org.springframework:spring-beans:jar:4.2.3.RELEASE:compile
[INFO] | +- org.springframework:spring-context:jar:4.2.3.RELEASE:compile
[INFO] | | \- org.springframework:spring-aop:jar:4.2.3.RELEASE:compile
[INFO] | | \- aopalliance:aopalliance:jar:1.0:compile
[INFO] | +- org.springframework:spring-core:jar:4.2.3.RELEASE:compile
[INFO] | | \- commons-logging:commons-logging:jar:1.2:compile
[INFO] | +- org.springframework:spring-expression:jar:4.2.3.RELEASE:compile
[INFO] | \- org.springframework:spring-web:jar:4.2.3.RELEASE:compile
[INFO] +- org.springframework.data:spring-data-cassandra:jar:1.4.5.RELEASE:compile
[INFO] | +- org.springframework.data:spring-cql:jar:1.4.5.RELEASE:compile
[INFO] | | \- com.google.guava:guava:jar:19.0:compile
[INFO] | +- org.springframework.data:spring-data-commons:jar:1.12.5.RELEASE:compile
[INFO] | +- com.datastax.cassandra:cassandra-driver-dse:jar:2.1.7.1:compile
[INFO] | | \- com.datastax.cassandra:cassandra-driver-core:jar:2.1.7.1:compile
[INFO] | | +- io.netty:netty-handler:jar:4.0.27.Final:compile
[INFO] | | | +- io.netty:netty-buffer:jar:4.0.27.Final:compile
[INFO] | | | | \- io.netty:netty-common:jar:4.0.27.Final:compile
[INFO] | | | +- io.netty:netty-transport:jar:4.0.27.Final:compile
[INFO] | | | \- io.netty:netty-codec:jar:4.0.27.Final:compile
[INFO] | | \- com.codahale.metrics:metrics-core:jar:3.0.2:compile
[INFO] | \- org.slf4j:jcl-over-slf4j:jar:1.7.21:runtime
[INFO] +- org.springframework:spring-jdbc:jar:4.3.3.RELEASE:compile
[INFO] | \- org.springframework:spring-tx:jar:4.3.3.RELEASE:compile
[INFO] +- org.slf4j:slf4j-api:jar:1.7.5:compile
[INFO] \- org.slf4j:slf4j-simple:jar:1.7.5:compile
答案 0 :(得分:0)
更新:我的记录器现在正在工作,虽然我不确定我做了什么使其工作的两件事情之一:1)在Project Structure-&gt; Artifacts选项卡下,我点击添加新的并添加新工件然后删除它或者2)重新启动应用程序和计算机。对不起,我无法准确确定解决方案是什么。