11

SLF4JLoggerContext cannot be cast to LoggerContext

 3 years ago
source link: https://jimolonely.github.io/2019/09/29/java/073-SLF4JLoggerContext-cannot-be-cast-to-LoggerContext/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

SLF4JLoggerContext cannot be cast to LoggerContext

org.apache.logging.slf4j.SLF4JLoggerContext cannot be cast to org.apache.logging.log4j.core.LoggerContext.

参考https://stackoverflow.com/questions/49688304/slf4jloggercontext-cannot-be-cast-to-loggercontext

解决办法:移除spring-boot-starter-web里的log4j-to-slf4j的依赖

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-to-slf4j</artifactId>
</exclusion>
</exclusions>
</dependency>

这样产生的结果是:spring的日志输出将轮为logback,而其他日志使用log4j

Share


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK