多个Log4J绑定错误

时间:2016-02-11 22:33:38

标签: logging

在我的应用程序中,我收到以下WARN消息:

[info] Resolving jline#jline;2.12.1 ...
[info] Done updating.
[info] Running com.test.KafkaConsumerBoot 
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/Users/joe/.ivy2/cache/org.slf4j/slf4j-log4j12/jars/slf4j-log4j12-1.6.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/Users/joe/.ivy2/cache/ch.qos.logback/logback-classic/jars/logback-classic-1.1.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
log4j:WARN No appenders could be found for logger (akka.event.slf4j.Slf4jLogger).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.

据我所知,某处使用了一些重复的日志库,但是哪一个呢?我将以下定义为我的应用程序依赖项:

  object Libraries {
    val typesafeCfg  = "com.typesafe"      %  "config"     % Versions.typesafeConfig
    val playJson     = "com.typesafe.play" %% "play-json"  % Versions.playJson
    val playHttp     = "com.typesafe.play" %% "play-ws"    % Versions.playHttp

    // spray http server libraries
    val sprayRouting = "io.spray" %%  "spray-routing" % Versions.sprayVersion
    val sprayHttp    = "io.spray" %%  "spray-can"     % Versions.sprayVersion

    val monifu       = "org.monifu"        %% "monifu"    % Versions.monifu
    val kafka        = "org.apache.kafka"  %% "kafka"     % Versions.kafka
    val jodaTime     = "joda-time"         %  "joda-time" % Versions.jodaTime

    val log4j        = "log4j"             %  "log4j"  % Versions.log4j
    val scalaLogging = "com.typesafe.scala-logging" %% "scala-logging" % Versions.scalaLogging
    val slf4J        = "org.slf4j" % "slf4j-api" % Versions.slf4J

    val scalaTest    = "org.scalatest" %% "scalatest" % Versions.scalaTest % "test"
  }

1 个答案:

答案 0 :(得分:0)

解决方案是:

"org.apache.kafka" % "kafka-streams" % kafkaVersion exclude("log4j", "log4j") exclude("org.slf4j","slf4j-log4j12"),