我收到Failed to load class "org.slf4j.impl.StaticLoggerBinder"错误.我想将记录器写入文件.所以我使用log4j.jar并使用apache tomcat服务器.
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.
Run Code Online (Sandbox Code Playgroud)
Kon*_*tis 14
首先.关于依赖性.
要添加SLF4J,您必须在您的pom.xml中放置一个且只有一个依赖项.这取决于您选择使用的实施方式.您在pom.xml中添加的每个依赖项都会自动添加到类路径中.如果下面的依赖项之一由另一个依赖项提供,那么您可以省略它.不要忘记,即使依赖项是由另一个依赖项提供的,您也必须只包含一个.请注意,我已从依赖项中省略了该版本.使用最新的.
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version></version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version></version>
<scope>compile</scope>
</dependency>
Run Code Online (Sandbox Code Playgroud)
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version></version>
<scope>compile</scope>
</dependency>
Run Code Online (Sandbox Code Playgroud)
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-jdk14</artifactId>
<version></version>
<scope>compile</scope>
</dependency>
Run Code Online (Sandbox Code Playgroud)
现在关于构建maven项目时遇到的恼人错误.如果只有上述依赖项中的一个后仍然得到SLF4J:无法加载类"org.slf4j.impl.StaticLoggerBinder".然后你面临来自m2e的错误.
当使用捆绑的maven版本(m2e)时,Eclipse Juno和Indigo不会抑制消息SLF4J:无法加载类"org.slf4j.impl.StaticLoggerBinder".此行为存在于m2e版本1.1.0.20120530-0009及之后.
虽然,这表示为错误,您的日志将正常保存.在修复此错误之前,突出显示的错误仍然存在.有关m2e支持网站的更多信息.
当前可用的解决方案是使用外部maven版本而不是捆绑的Eclipse版本.您可以在下面的问题中找到有关此错误的此解决方案和更多详细信息,我认为这些错误描述了您遇到的同一问题.
SLF4J:无法加载类"org.slf4j.impl.StaticLoggerBinder".错误
| 归档时间: |
|
| 查看次数: |
34179 次 |
| 最近记录: |