Search code examples
loggingakkaslf4jlagom

Why does lagom use an async appender in production


The following resource states that Lagom uses an async logger in production. https://www.lagomframework.com/documentation/1.3.x/java/SettingsLogger.html

However, lagom also uses akka and akka advises that you use the akka-way of logging in your actors --> https://doc.akka.io/docs/akka/2.5/logging.html?language=java

The akka-way of logging (via a LoggingAdapter) basically forwards all log messages to a Logging actor. This is done to minimize the impact of Logging on your actor --> the logging is done asynchronously by another actor.

Am I correct that the combo of these leads to double async logging? Is this a problem? Is the async logging of slf4j to be preferred above the akka way of logging or the other way around? Arguments pro, arguments con?


Solution

  • There are many places in Lagom that we need to log and where we are not inside an Actor. Also, with respect to user code. Most user code is written outside an Actor but is run inside an Actor.

    It's true that there is an overhead when logging through ActorLogging, but that's preferable than user-defined blocking logger that happens to be called from inside an Actor.