Play Akka logger doesn't output debug messages

2019-06-23 16:24发布

问题:

I'm trying to setup debug logging to console from Akka actors with Scala 2.11.6 and Play 2.4.6. So I see info messages with this config, but not debug:

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" />

usage:

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")
  }
}

I see debug messages from the app (thrown in controller, for example), but not from actors. Starting app like activator debug run

回答1:

In application.conf, try changing to:

akka {
    loglevel = "DEBUG"
}

You have "level" instead of "loglevel". That fixed this for me.