是否可以用 logback 从传递依赖替换 log4j?这是我的 gradle 依赖项(https://github.com/geoHeil/lab04/blob/master/build.gradle):
dependencies {
compile group: 'org.apache.hadoop', name: 'hadoop-common', version: '2.7.1'
compile group: 'org.apache.hadoop', name: 'hadoop-client', version: '2.7.1'
compile group: 'org.apache.hadoop', name: 'hadoop-mapreduce-client-core', version: '2.7.1'
compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.13'
compile group: 'ch.qos.logback', name: 'logback-classic', version: '1.1.3'
}
configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
if (details.requested.name == 'log4j') {
//prefer 'log4j-over-slf4j' over 'log4j', with fixed version:
details.useTarget "ch.qos.logback:logback-classic:1.1.3"
}
}
我的情况:
- 我是 Gradle 新手
- 从事 Hadoop 项目
- 想要使用当前的记录器,例如
logback
现在,即使应该替换 log4j,它似乎也不起作用。警告仍然存在:
log4j:WARN No appenders could be found for logger
(org.apache.hadoop.util.Shell).
log4j:WARN Please initialize the log4j system properly.