SLF4J:Class 路径包含多个 SLF4J 绑定。打印在控制台上的消息
SLF4J: Class path contains multiple SLF4J bindings. message printed on console
我想在控制台上打印日志并将它们写入文件中。在我使用 akka 记录器的 scala 项目中,这里是我的 build.sbt
libraryDependencies ++= Seq("org.mongodb" %% "casbah" % "2.8.0",
"org.slf4j" % "slf4j-simple" % "1.7.12",
"org.elasticsearch" % "elasticsearch" % "1.5.0",
"org.scalatest" %% "scalatest" % "2.2.1" % "test"
withSources() withJavadoc(),
"org.easymock" % "easymock" % "3.1" withSources() withJavadoc(),
"org.mockito" % "mockito-all" % "1.9.5",
"com.typesafe.akka" %% "akka-actor" % "2.3.6",
"ch.qos.logback" % "logback-classic" % "1.0.9",
"com.typesafe.akka" %% "akka-slf4j" % "2.3.9")
这是我的代码的一部分
import akka.event.Logging
val log = Logging(context.system, this)
case RegularAdminWriteInMongo =>
log.debug("writing to mongo")
log.info("message received RegularAdminWriteInMongo")
当我 运行 我的程序在 sbt 中打印以下消息时
SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found
binding in [jar: file: /home/sara / .ivy2 / cache / org.slf4j / slf4j
- simple / jars / slf4j - simple - 1.7.12.jar!/org/slf4j / impl / StaticLoggerBinder.class] SLF4J: Found binding in [jar: file:
/home/sara / .ivy2 / cache / ch.qos.logback / logback - classic / jars
/ logback - classic - 1.0.9.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.SimpleLoggerFactory]
[ArteciateActorSystem - akka.actor. default -dispatcher - 3] INFO
akka.event.slf4j.Slf4jLogger - Slf4jLogger
started[ArteciateActorSystem - akka.actor.
default -dispatcher - 2] INFO
models.AdminUserModels.AdminUserModelsActors.RegularAdminWriteMongoActor
- message received RegularAdminWriteInMongo
在打印我的其他 println 语句之后,请帮助我如何停止显示此消息,也请不要将我的问题标记为重复,因为它在我调查之前已经被问过,但它没有解决我的问题。 .请帮忙谢谢
错误消息已经告诉了您需要知道的一切。消息中提供的 link (http://www.slf4j.org/codes.html#multiple_binding) 表示:
SLF4J API is designed to bind with one and only one underlying logging framework at a time. If more than one binding is present on the class path, SLF4J will emit a warning, listing the location of those bindings.
您的类路径包含两个 SLF4J 绑定:
/home/sara/.ivy2/cache/org.slf4j/slf4j-simple/jars/slf4j-simple-1.7.12.jar
和
/home/sara/.ivy2/cache/ch.qos.logback/logback-classic/jars/logback-classic-1.0.9.jar
确保您的类路径上只有一个绑定,警告将不会再次显示。
总结一下:从依赖中删除 slf4j-simple,logback-classic 就足够了。
我想在控制台上打印日志并将它们写入文件中。在我使用 akka 记录器的 scala 项目中,这里是我的 build.sbt
libraryDependencies ++= Seq("org.mongodb" %% "casbah" % "2.8.0",
"org.slf4j" % "slf4j-simple" % "1.7.12",
"org.elasticsearch" % "elasticsearch" % "1.5.0",
"org.scalatest" %% "scalatest" % "2.2.1" % "test"
withSources() withJavadoc(),
"org.easymock" % "easymock" % "3.1" withSources() withJavadoc(),
"org.mockito" % "mockito-all" % "1.9.5",
"com.typesafe.akka" %% "akka-actor" % "2.3.6",
"ch.qos.logback" % "logback-classic" % "1.0.9",
"com.typesafe.akka" %% "akka-slf4j" % "2.3.9")
这是我的代码的一部分
import akka.event.Logging
val log = Logging(context.system, this)
case RegularAdminWriteInMongo =>
log.debug("writing to mongo")
log.info("message received RegularAdminWriteInMongo")
当我 运行 我的程序在 sbt 中打印以下消息时
SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar: file: /home/sara / .ivy2 / cache / org.slf4j / slf4j - simple / jars / slf4j - simple - 1.7.12.jar!/org/slf4j / impl / StaticLoggerBinder.class] SLF4J: Found binding in [jar: file: /home/sara / .ivy2 / cache / ch.qos.logback / logback - classic / jars / logback - classic - 1.0.9.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.SimpleLoggerFactory] [ArteciateActorSystem - akka.actor. default -dispatcher - 3] INFO akka.event.slf4j.Slf4jLogger - Slf4jLogger started[ArteciateActorSystem - akka.actor. default -dispatcher - 2] INFO models.AdminUserModels.AdminUserModelsActors.RegularAdminWriteMongoActor - message received RegularAdminWriteInMongo
在打印我的其他 println 语句之后,请帮助我如何停止显示此消息,也请不要将我的问题标记为重复,因为它在我调查之前已经被问过,但它没有解决我的问题。 .请帮忙谢谢
错误消息已经告诉了您需要知道的一切。消息中提供的 link (http://www.slf4j.org/codes.html#multiple_binding) 表示:
SLF4J API is designed to bind with one and only one underlying logging framework at a time. If more than one binding is present on the class path, SLF4J will emit a warning, listing the location of those bindings.
您的类路径包含两个 SLF4J 绑定:
/home/sara/.ivy2/cache/org.slf4j/slf4j-simple/jars/slf4j-simple-1.7.12.jar
和
/home/sara/.ivy2/cache/ch.qos.logback/logback-classic/jars/logback-classic-1.0.9.jar
确保您的类路径上只有一个绑定,警告将不会再次显示。
总结一下:从依赖中删除 slf4j-simple,logback-classic 就足够了。