Failed to load class "org.slf4j.impl.StaticLoggerBinder" 来自 SLF4J 的消息错误
Failed to load class "org.slf4j.impl.StaticLoggerBinder" message error from SLF4J
我正在使用 Akka 和 Akka-http 开发一个简单的服务器。
当我 运行 应用到 IntelliJ 中时,我总是在标准输出中收到以下错误消息:
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'
我有 application.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 的特定要求。
SLF4J 只是一个外观,始终需要一个日志记录后端。
另请注意,如果您选择 Logback,建议提供包含日志设置的 logback.xml
文件,请参阅 以供参考。
关于在 Akka 中登录,您需要了解的所有信息都在 docs。
我正在使用 Akka 和 Akka-http 开发一个简单的服务器。
当我 运行 应用到 IntelliJ 中时,我总是在标准输出中收到以下错误消息:
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'
我有 application.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 的特定要求。 SLF4J 只是一个外观,始终需要一个日志记录后端。
另请注意,如果您选择 Logback,建议提供包含日志设置的 logback.xml
文件,请参阅
关于在 Akka 中登录,您需要了解的所有信息都在 docs。