Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

akka.actor.ActorLogging does not log the stack trace of exception by logback

I am using Logback + SLF4J to do logging for those actors with trait of akka.actor.ActorLogging. However, when I do the code log.error("Error occur!", e), the stack trace of the exception e is not logged, but only print a line of Error occur! WARNING arguments left: 1. I wonder why and how to print the stack trace in the log file. Thank you. The following is my logback.groovy file configuration.

appender("FILE", RollingFileAppender) {
  file = "./logs/logd.txt"
  append = true
  rollingPolicy(TimeBasedRollingPolicy) {
    fileNamePattern = "./logs/logd.%d{yyyy-MM-dd}.log"
    maxHistory = 30
  }
  encoder(PatternLayoutEncoder) {
    pattern = "%date{ISO8601} [%thread] %-5level %logger{36} %X{sourceThread} - %msg%n"
  }
}
root(DEBUG, ["FILE"])
like image 975
Dzanvu Avatar asked Sep 22 '14 06:09

Dzanvu


1 Answers

Akka has separate logging, which is configured in Akka's application.conf. If you want bridge to SLF4J/Logback - use thеsе settings:

akka {
  loggers = ["akka.event.slf4j.Slf4jLogger"]
  loglevel = "DEBUG"
}

See: http://doc.akka.io/docs/akka/2.0/scala/logging.html

As far as I can see here, reason (Throwable) should be the first argument of log.error:

 def error(cause: Throwable, message: String)

That's why you see "WARNING arguments left" - your Throwable argument was just ignored.

like image 188
dk14 Avatar answered Nov 09 '22 10:11

dk14