gpt4 book ai didi

logging - SLF4J:类路径包含多个 SLF4J 绑定(bind)。控制台上打印的消息

转载 作者:行者123 更新时间:2023-12-04 02:43:25 24 4
gpt4 key购买 nike

我想在控制台上打印日志并将它们写入文件。在我使用 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 语句被打印出来,请帮助我如何停止显示此消息,也请不要将我的问题标记为重复,因为在我查看它之前提出的问题,但它不能解决我的问题..请帮助谢谢

最佳答案

错误消息已经告诉您您需要知道的一切。消息中提供的链接 (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 的两个绑定(bind):

/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



确保您的类路径上只有一个绑定(bind),并且不会再次显示警告。

总结一下: 从依赖项中删除 slf4j-simple,logback-classic 就足够了。

关于logging - SLF4J:类路径包含多个 SLF4J 绑定(bind)。控制台上打印的消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29671133/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com