Lagom uses SLF4J for logging, backed by Logback as its default logging engine. Here is a short example showcasing how you can access the logger:

package docs.logging;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class LoggingExample {
    private final Logger log = LoggerFactory.getLogger(LoggingExample.class);

    public void demonstrateLogging(String msg) {
        log.debug("Here is a message at debug level: {}.", msg);

And you can read of more advanced usages on the SLF4J user manual.

If you’re using maven, you’ll need to add the Lagom logback dependency to your classpath to get Logback support:


If you’re using sbt, you’ll automatically get the Lagom logback support when you enable the LagomJava plugin on a project:

lazy val usersImpl = (project in file("usersImpl"))
  .enablePlugins(LagomJava) // Lagom logging module is automatically added to the classpath

If you’d like to use the Lagom logger module on a project that doesn’t have the LagomJava sbt plugin enabled (e.g., a Lagom API project), simply add the Lagom logger module as an explicit library dependency:

// `LagomImport` provides a few handy alias to several Lagom modules
import com.lightbend.lagom.sbt.LagomImport.lagomLogback

lazy val usersApi = (project in file("usersApi"))
  .settings(libraryDependencies += lagomLogback)

The Lagom logger module includes a default logback configuration. Read Configuring Logging for details.

Found an error in this documentation? The source code for this page can be found here. Please feel free to edit and contribute a pull request.