Detected both log4j-over-slf4j.jar AND bound slf4j-log4j12.jar on the class path, preempting StackOv

  • 原因:slf4j-log4j12模块的目的是将对 SLF4J 的调用重定向到 log4j。log4j-over-slf4j模块的目的是将对 log4j 记录器的调用重定向到 SLF4J。如果 SLF4J 与slf4j-log4j12.jar绑定, 并且log4j-over-slf4j.jar也存在于ClassPath中,第一次调用 SLF4J 或 log4j logger 后不可避免地会立即发生*Error

  • 解决方案:

    1. 点击项目,Maven——Show Diagram

      Detected both log4j-over-slf4j.jar AND bound slf4j-log4j12.jar on the class path, preempting StackOv

    2. 搜索slf4j-log4j12(这里我已经排除依赖了,就用log4j-to-slf4j举例子)

      Detected both log4j-over-slf4j.jar AND bound slf4j-log4j12.jar on the class path, preempting StackOv

    3. 找到对应的依赖双击,再右键——Exclude即可

      Detected both log4j-over-slf4j.jar AND bound slf4j-log4j12.jar on the class path, preempting StackOv

    4. 最后观察pom文件可以看到即可,重新启动项目即可

      <dependency>
      	<groupId>com.youzan.cloud</groupId>
      	<artifactId>dennis-chain-baihuo-biz</artifactId>
      	<version>${project.version}</version>
      	<exclusions>
      		<exclusion>
      			<artifactId>slf4j-log4j12</artifactId>
      			<groupId>org.slf4j</groupId>
      		</exclusion>
      	</exclusions>
      </dependency>
      
上一篇:Mybatis日志(重点)


下一篇:使用Log4j的步骤