scala – 无法从SLF4J加载类“org.slf4j.impl.StaticLoggerBinde
发布时间:2020-12-16 19:10:37 所属栏目:安全 来源:网络整理
导读:我正在使用Akka和Akka-http开发一个简单的服务器. 当我在IntelliJ中运行应用程序时,我总是在stdout中收到以下错误消息: SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".SLF4J: Defaulting to no-operation (NOP) logger implementationS
我正在使用Akka和Akka-http开发一个简单的服务器.
当我在IntelliJ中运行应用程序时,我总是在stdout中收到以下错误消息: SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". SLF4J: Defaulting to no-operation (NOP) logger implementation SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details. 我在build.gradle中有以下依赖项: compile 'org.scala-lang:scala-library:2.12.1' compile 'com.typesafe.akka:akka-actor_2.12:2.4.17' compile 'com.typesafe.akka:akka-stream_2.12:2.4.17' compile 'com.typesafe.akka:akka-http_2.12:10.0.4' compile 'com.typesafe.akka:akka-http-spray-json_2.12:10.0.4' compile 'com.typesafe.akka:akka-slf4j_2.12:2.4.17' 我有app.conf,如下所示: akka { loggers = ["akka.event.slf4j.Slf4jLogger"] loglevel = "INFO" stdout-loglevel = "INFO" logging-filter = "akka.event.slf4j.Slf4jLoggingFilter" ... } 最后,我正在使用这样的Logging: object HttpServer extends App with JsonSupport { override def main(args: Array[String]): Unit = { val config = ConfigFactory.load() implicit val system = ActorSystem(config.getString("application.actor-system")) implicit val materializer = ActorMaterializer() // needed for the future flatMap/onComplete in the end implicit val executionContext = system.dispatcher val logger = Logging(system,getClass) 任何人都可以知道为什么我总是得到错误陈述? 解决方法
您需要提供SLF4J后端 – Akka
docs建议使用Logback.
这可以通过将其添加到您的依赖项来实现,如下所示.您可能还希望将依赖项标记为Runtime,因为它不需要编译时. libraryDependencies += "ch.qos.logback" % "logback-classic" % "1.1.3" % Runtime 请注意,这不是Akka的具体要求. 另请注意,如果选择Logback,建议使用日志记录设置提供logback.xml文件,请参阅this answer以获取参考. 有关在Akka内登录的所有信息,请访问docs. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |