Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to solve log4j-slf4j-impl cannot be present with log4j-to-slf4j error reporting

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article introduces the knowledge of "how to solve the log4j-slf4j-impl cannot be present with log4j-to-slf4j error report". In the operation of actual cases, many people will encounter such a dilemma. Then let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

When building a project, the following error occurred at startup:

SLF4J: Class path contains multiple SLF4J bindings.SLF4J: Found binding in [SLF4J: Found binding in] SLF4J: jar:file:/D:/buildSoft/java/maven/jar-center/ch/qos/logback/logback-classic/1.2.3/logback- [jar:file:/D:/buildSoft/java/maven/jar-center/ch/qos/logback/logback-classic/1.2.3/logback-] SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory] Exception in thread "main" java.lang.ExceptionInInitializerError at com.xt.gateway.GatewayApplication.main (GatewayApplication.java:22) Caused by: org.apache.logging.log4j.LoggingException: log4j-slf4j-impl cannot be present with log4j-to- Slf4j at org.apache.logging.slf4j.Log4jLoggerFactory.validateContext (Log4jLoggerFactory.java:49) at org.apache.logging.slf4j.Log4jLoggerFactory.newLogger (Log4jLoggerFactory.java:39) at org.apache.logging.slf4j.Log4jLoggerFactory.newLogger (Log4jLoggerFactory.java:30) at org.apache.logging.log4j.spi.AbstractLoggerAdapter.getLogger (AbstractLoggerAdapter.java:54) at org.apache.logging.slf4j.Log4jLoggerFactory.getLogger (Log4jLoggerFactory.java:30) At org.slf4j.LoggerFactory.getLogger (LoggerFactory.java:363) at org.apache.commons.logging.LogAdapter$Slf4jAdapter.createLocationAwareLog (LogAdapter.java:130) at org.apache.commons.logging.LogAdapter.createLog (LogAdapter.java:91) at org.apache.commons.logging.LogFactory.getLog (LogFactory.java:67) at org.apache.commons.logging.LogFactory.getLog (LogFactory.java:59) at org.springframework.boot.SpringApplication . (SpringApplication.java:196). 1 more

Because the project spring boot uses logback by default, but I specify log4j2 here

Org.springframework.boot spring-boot-starter-log4j2 solution

You only need to exclude the corresponding spring boot starter dependency from the corresponding log dependency.

Org.springframework.boot spring-boot-starter-actuator org.springframework.boot spring-boot-starter-logging org.springframework.cloud spring-cloud-starter-gateway Org.springframework.boot spring-boot-starter-logging org.springframework.boot spring-boot-starter-web org.springframework.boot spring-boot-starter-logging This is the end of the content of "how to solve log4j-slf4j-impl cannot be present with log4j-to-slf4j errors". Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report