springboot2.0.4整合log4j2不生效

log4j2的配置文件名为log4j2-spring.xml

<dependency>
  <groupId>org.springframework.bootgroupId>
  <artifactId>spring-boot-starter-webartifactId>
  <exclusions>
      <exclusion>
          <groupId>org.springframework.bootgroupId>
          <artifactId>spring-boot-starter-loggingartifactId>
      exclusion>
  exclusions>
dependency>
<dependency> 
    <groupId>org.springframework.bootgroupId>
    <artifactId>spring-boot-starter-log4j2artifactId>
    <version>2.0.4.RELEASEversion>
dependency>

上面是我的配置,但是就是没生效。
发现一个警告:

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/C:/Users/x1c/.m2/repository/ch/qos/logback/logback-classic/1.2.3/logback-classic-1.2.3.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/C:/Users/x1c/.m2/repository/org/apache/logging/log4j/log4j-slf4j-impl/2.10.0/log4j-slf4j-impl-2.10.0.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [ch.qos.logback.classic.util.ContextSelectorStaticBinder]

包冲突了,删掉了,log4j2还是不生效。
后来怀疑还是包冲突:
springboot2.0.4整合log4j2不生效_第1张图片
springboot2.0.4整合log4j2不生效_第2张图片

在依赖里一个一个的找,看看有没有log4j的包,全部排除掉,就好了

按理说log4j2只需要引入自己的依赖就行,如下图:
springboot2.0.4整合log4j2不生效_第3张图片

你可能感兴趣的:(log4j2)