Cra*_*hax 3 tomcat log4j intellij-idea slf4j maven
我在帖子中找不到解决方案之后打开这篇文章: 无法加载类"org.slf4j.impl.StaticLoggerBinder"错误
我还在IntelliJ中打开了一个Maven项目,并在tomcat7插件中选择'redeploy'选项后出现以下错误:
SLF4J:无法加载类"org.slf4j.impl.StaticLoggerBinder".SLF4J:默认为无操作(NOP)记录器实现SLF4J:有关更多详细信息,请参阅http://www.slf4j.org/codes.html#StaticLoggerBinder.
在附加的链接中,建议转到File-> Project Structure - > Artifacts并检查错误.这就是我所看到的:
我在pom.xml文件中也有以下依赖项:
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.5</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.5.6</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.21</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
你能帮我找错吗?
也许有两个问题:
为了重现你的错误,我创建了这个迷你程序:
package de.so;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class DemoSlf4j
{
private static Logger logger = LoggerFactory.getLogger(DemoSlf4j.class);
public static void main(String[] args)
{
logger.error("Start ...");
}
}
Run Code Online (Sandbox Code Playgroud)
与只有这些依赖关系(同你使用)在pom.xml中:
<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.5</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.5.6</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.21</version>
</dependency>
</dependencies>
Run Code Online (Sandbox Code Playgroud)
我有这些消息:
SLF4J:类路径包含多个SLF4J绑定.SLF4J:在[jar:file:/ D:/Maven-Repo/org/slf4j/slf4j-log4j12/1.5.6/slf4j-log4j12-1.5.6.jar!/org/slf4j/impl/StaticLoggerBinder.class中找到绑定] SLF4J:在[jar:file:/ D:/Maven-Repo/org/slf4j/slf4j-simple/1.7.21/slf4j-simple-1.7.21.jar!/ org/slf4j/impl/StaticLoggerBinder中找到绑定. class] SLF4J:请参阅http://www.slf4j.org/codes.html#multiple_bindings以获得解释.SLF4J:实际绑定的类型为[org.slf4j.impl.Log4jLoggerFactory] SLF4J:slf4j绑定所请求的版本1.5.6与[1.6,1.7] SLF4J不兼容:请参阅 http://www.slf4j.org/ codes.html#version_mismatch了解更多详情.log4j:WARN没有为logger找到appender(de.so.DemoSlf4j).log4j:WARN请正确初始化log4j系统.
当我使用这些依赖项时,一切都很好.看看版本!
<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.21</version> <!-- or use LATEST -->
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.21</version> <!-- or use LATEST -->
</dependency>
</dependencies>
Run Code Online (Sandbox Code Playgroud)
如果您使用的org.slf4j:slf4j-log4j12:1.7.21是slf4j-simple(更有可能用于生产目的),您将获得:
log4j:WARN没有为logger找到appender(de.so.DemoSlf4j).log4j:WARN请正确初始化log4j系统.log4j:WARN有关详细信息,请参阅 http://logging.apache.org/log4j/1.2/faq.html#noconfig.
这样做:
| 归档时间: |
|
| 查看次数: |
22019 次 |
| 最近记录: |