播放Akka记录器不会将调试消息输出到控制台

时间:2016-01-19 06:39:05

标签: scala logging playframework-2.0 akka slf4j

我尝试使用Scala 2.11.6和播放2.4.6从Akka演员设置调试日志记录到控制台。所以我看到这个配置的信息消息,但没有调试:

application.conf:

akka {
  loggers = ["akka.event.slf4j.Slf4jLogger"]
  level = "DEBUG"
  logging-filter = "akka.event.slf4j.Slf4jLoggingFilter"
}

logback.xml:

<logger name="akka" level="DEBUG" />
<logger name="actors" level="DEBUG" />

用法:

package actors

import akka.actor._
import akka.event.Logging

object DispatchActor {
  def props(out: ActorRef) = Props(new DispatchActor(out))
}

class DispatchActor(out: ActorRef) extends Actor {
  val log = Logging(context.system, this)
  log.debug("akka started: info")


  def receive = {
    case msg: String =>
      log.debug("actor received a message")
      out ! ("I received your message: " + msg)
  }

  override def postStop() = {
    log.info("actor closed")
  }
}

我看到来自app的调试消息(例如,抛出控制器),但不是来自actor。启动应用activator debug run

1 个答案:

答案 0 :(得分:3)

在application.conf中,尝试更改为:

akka {
    loglevel = "DEBUG"
}

你有“级别”而不是“loglevel”。这为我解决了这个问题。