最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

springBoot啟動報錯log4j沖突的解決方案

 更新時間:2021年07月30日 10:36:12   作者:曉明兄  
這篇文章主要介紹了springBoot啟動報錯log4j沖突的解決方案,具有很好的參考價值,希望對大家有所幫助。

springBoot啟動報錯log4j沖突

先上一段報錯內(nèi)容

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/D:/soft/apache-tomcat-8.5.31/webapps/ui/WEB-INF/lib/log4j-slf4j-impl-2.7.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/D:/soft/apache-tomcat-8.5.31/webapps/ui/WEB-INF/lib/logback-classic-1.1.11.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/D:/soft/apache-tomcat-8.5.31/webapps/ui/WEB-INF/lib/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]
......
Caused by: java.lang.IllegalArgumentException: LoggerFactory is not a Logback LoggerContext but Logback is on the classpath. Either remove Logback or the competing implementation (class org.apache.logging.slf4j.Log4jLoggerFactory loaded from file:/D:/soft/apache-tomcat-8.5.31/webapps/ui/WEB-INF/lib/log4j-slf4j-impl-2.7.jar). If you are using WebLogic you will need to add 'org.slf4j' to prefer-application-packages in WEB-INF/weblogic.xml: org.apache.logging.slf4j.Log4jLoggerFactory

springBoot 本地報錯,查了一番,是logback搞得鬼,打開pom依賴樹,搜索logback,發(fā)現(xiàn)在spring-boot-starter-web下有間接依賴上logback-classisc,搜索大神們的解答,就是在有這個依賴的dependency中除去他就行了。

<dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
        <exclusions>
                <exclusion>
                    <groupId>ch.qos.logback</groupId>
                   <artifactId>logback-classic</artifactId>
                </exclusion>
           </exclusions>
</dependency>

SpringBoot啟用log4j日志

pom.xml

  <!--排除默認(rèn)的日志 --> 
  <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter</artifactId>
      <exclusions>
          <exclusion>
              <groupId>org.springframework.boot</groupId>
              <artifactId>spring-boot-starter-logging</artifactId>
          </exclusion>
      </exclusions>
  </dependency>
   <!--啟用log4j日志 -->  
  <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-log4j</artifactId>
    <version>1.2.8.RELEASE</version>
  </dependency>

log4j.properties

log4j.rootLogger=debug, ServerDailyRollingFile, stdout 
log4j.appender.ServerDailyRollingFile=org.apache.log4j.DailyRollingFileAppender 
log4j.appender.ServerDailyRollingFile.DatePattern='.'yyyy-MM-dd 
log4j.appender.ServerDailyRollingFile.File=C\://logs/notify-subscription.log 
log4j.appender.ServerDailyRollingFile.layout=org.apache.log4j.PatternLayout 
log4j.appender.ServerDailyRollingFile.layout.ConversionPattern=%d - %m%n 
log4j.appender.ServerDailyRollingFile.Append=true

log4j.appender.stdout=org.apache.log4j.ConsoleAppender 
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout 
log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH\:mm\:ss} %p [%c] %m%n

log4j.properties放在resources目錄下,這個log4j是隨便配的。

以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論

武穴市| 阜康市| 汕头市| 山西省| 文成县| 定安县| 锡林浩特市| 高雄市| 建湖县| 米泉市| 临颍县| 乳源| 城固县| 四会市| 潞城市| 利川市| 竹北市| 杭锦旗| 开封县| 察雅县| 汽车| 延吉市| 泽库县| 舟山市| 渭南市| 沙田区| 富阳市| 内乡县| 缙云县| 吉林省| 常州市| 三河市| 永善县| 新宁县| 奉贤区| 南和县| 桃园市| 会泽县| 仁怀市| 宝山区| 商洛市|