3
我正在开发一个使用Akka和Akka-http的简单服务器。未能从SLF4J加载类“org.slf4j.impl.StaticLoggerBinder”消息错误
我总是在标准输出以下错误消息,当我运行的应用程序到的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"
...
}
最后,我用这样的日志记录:
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)
任何人都可以知道为什么我总是得到错误声明吗?
是的,它的工作原理!我不能相信我忘了!谢谢你的帮助! –
这对我有用 - 摆脱了警告,但我得到了几个屏幕价值的调试和信息日志。上面的答案中的文档链接有助于,正如[本答案](https://stackoverflow.com/a/32003907)(基本上,添加'logback.xml'并根据需要进行配置)。 – fazy