我将把一个slf4j实现(基于logback的公司框架)集成到spring boot 2.0中 . 在我的进展中,我发现默认的logback依赖性与我自己的依赖项冲突 . 以这种方式排除 spring-boot-starter-logging
模块:
<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>
冲突的错误消失了,但似乎spring boot使用我的库作为slf4j日志记录实现,就像之前的方式一样,我的自定义函数中没有任何工作 .
我想知道是否有一种方法可以用我的代码替换日志系统以使其工作但是在spring.io网站上没有找到关于此的参考 .
3 回答
要禁用Spring Boot的LoggingSystem(默认为LogbackLoggingSystem),需要设置以下系统属性
这是在https://docs.spring.io/spring-boot/docs/current/reference/html/howto-logging.html和https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-logging.html以供参考 .
错误
由log4j-sl4j-impl和log4j-to-sl4j的call-loop生成 .
你可以解决不包括log4j到slf4j:
Remove login default dependency in the Spring-boot-starter-web project
我们需要在类路径中放置一个名为以下属性文件之一的文件,然后重新启动项目
log4j2-spring.xml
log4j2.xml