是否可以将log4j从可传递依赖项替换为logback?这是我的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"
}
}
我的案子:
我刚到grad尔
从事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.
1条答案
按热度按时间gzszwxb41#
我不确定这是最好的还是“正确”的答案。但至少
WARN
消息已消失: