当前位置 博文首页 > 莫忘、初心:java.lang.IllegalArgumentException: LoggerFactor

    莫忘、初心:java.lang.IllegalArgumentException: LoggerFactor

    作者:[db:作者] 时间:2021-08-04 21:54


    java服务启动报错:


    Exception提取:

    Exception in thread "main" 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:/Storage/idea/.m2/repository/org/apache/logging/log4j/
    	log4j-slf4j-impl/2.7/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
    

    具体异常

    Exception in thread "main" 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:/Storage/idea/.m2/repository/org/apache/logging/log4j/log4j-slf4j-impl/2.7/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
    	at org.springframework.util.Assert.instanceCheckFailed(Assert.java:389)
    	at org.springframework.util.Assert.isInstanceOf(Assert.java:327)
    	at org.springframework.boot.logging.logback.LogbackLoggingSystem.getLoggerContext(LogbackLoggingSystem.java:274)
    	at org.springframework.boot.logging.logback.LogbackLoggingSystem.beforeInitialize(LogbackLoggingSystem.java:98)
    	at org.springframework.boot.logging.LoggingApplicationListener.onApplicationStartingEvent(LoggingApplicationListener.java:231)
    	at org.springframework.boot.logging.LoggingApplicationListener.onApplicationEvent(LoggingApplicationListener.java:210)
    	at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
    	at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
    	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
    	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:122)
    	at org.springframework.boot.context.event.EventPublishingRunListener.starting(EventPublishingRunListener.java:69)
    	at org.springframework.boot.SpringApplicationRunListeners.starting(SpringApplicationRunListeners.java:48)
    	at org.springframework.boot.SpringApplication.run(SpringApplication.java:292)
    	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118)
    	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107)
    	at com.gk.business.user.GkHealthUserApplication.main(GkHealthUserApplication.java:21)
    
    

    问题原因

    该问题是由服务内部的logger依赖冲突印起来的

    解决方法:

    1. 排查日志依赖的版本号是否存在冲突
    2. 排查日志依赖的冲突
    cs
    下一篇:没有了