如何为版本启用登录 org.slf4j:'2.0.0-alpha1' in Spring boot

r12*_*123 12 java spring-mvc maven-plugin spring-boot

我使用 SLF4J 日志来打印所有日志。我正在使用最新版本的 org.slf4j。

实现 'org.slf4j:slf4j-api:2.0.0-alpha1'

实现 'org.slf4j:log4j-over-slf4j:2.0.0-alpha1'

但是我收到以下错误并且也没有打印日志。

SLF4J: No SLF4J providers were found.
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#noProviders for further details.
SLF4J: Class path contains SLF4J bindings targeting slf4j-api versions prior to 1.8.
SLF4J: Ignoring binding found at [jar:file:/home/user/.gradle/caches/modules-2/files-2.1/ch.qos.logback/logback-classic/1.2.3/7c4f3c474fb2c041d8028740440937705ebb473a/logback-classic-1.2.3.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#ignoredBindings for an explanation.
Run Code Online (Sandbox Code Playgroud)

日志在旧版本 (1.7.25) 上运行良好。是否需要在项目上添加或配置任何内容,以便可以打印这些日志

SST*_*SST 2

它将打印添加 slf4j-log4j12 而不是 slf4j-api 的消息

删除以下内容

implementation 'org.slf4j:slf4j-api:2.0.0-alpha1'
implementation 'org.slf4j:log4j-over-slf4j:2.0.0-alpha1'
Run Code Online (Sandbox Code Playgroud)

添加

implementation group: 'org.slf4j', name: 'slf4j-log4j12', version: '+'
Run Code Online (Sandbox Code Playgroud)