带有log4j 2.8.1的slf4j-log4j桥 [英] slf4j-log4j bridge with log4j 2.8.1
问题描述
我正在努力删除对log4j 1.x版本的所有依赖,因为它们已经停产.我的代码使用slf4j-log4j12桥.在 slf4j-log4j 的 Maven 中央编译依赖项中,log4j 的版本为 1.2.17,更新列显示为 2.8.1.
I am working on removing any dependencies on log4j 1.x versions as they have EOL'd. My code uses slf4j-log4j12 bridge. In maven central compile dependencies for slf4j-log4j shows log4j at version 1.2.17 with updates column showing 2.8.1.
因此,我尝试在build.gradle中执行以下操作,希望使用log4j-api-2.8.1代替默认情况下拉出的log4j-1.2.17.但这似乎不起作用.我仍然在依赖的jar中看到log4j-1.2.17.
So I tried following in build.gradle with the hope that log4j-api-2.8.1 would be used in place of log4j-1.2.17 which is pulled by default. But that doesn't seem to be working. I still see log4j-1.2.17 in the dependent jars.
所以我想问,这是根本不允许的吗?IE.有没有slf4j-log4j到log4j 2.8.1版本的桥,或者与此有关的2.x版本?本质上,我应该迁移代码以使用log4j-api-2.8.1.还是我在这里想念什么?
So I wanted to ask, is this something that is not allowed at all? I.e. there is no slf4j-log4j bridge to log4j 2.8.1 version or for that matter 2.x version? Essentially I should migrate my code to use log4j-api-2.8.1. Or am I missing something here?
dependencies {
compile group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.8.1'
compile group: 'org.slf4j', name: 'slf4j-log4j12', version: '1.7.25'
}
推荐答案
slf4j-log4j12
是log4j 1.2版的绑定.但是您需要log4j版本2(log4j2)绑定,该绑定名为 log4j-slf4j-impl
.
slf4j-log4j12
is a binding for log4j version 1.2. But you need log4j version 2 (log4j2) binding, which is named log4j-slf4j-impl
.
要同时使用slf4j和log4j2,您将需要:
To use slf4j along with log4j2, you will require:
- log4j-api(2.8.1)
- log4j-core(2.8.1)
- log4j-slf4j-impl(2.8.1)
- slf4j-api(1.7.25)
如果您对log4j 1.2版有任何实现和/或依赖性,则还需要:
If you have any implementation and/or dependency over log4j version 1.2, you will also require:
- log4j-1.2-api(2.8.1)
但是,在任何情况下都不应包括以下依赖项:
However, you should not include following dependencies in any case:
- log4j至slf4j(2.x)
- log4j(1.2.x)
这篇关于带有log4j 2.8.1的slf4j-log4j桥的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!