Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Convenient and performant logging in Scala
Tag: v1.1.0

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.


Scala logging library wrapping SLF4J and Log4j 2 in a convenient and performant fashion.

In principle the call of log messages should be avoided if the given log level is not enabled. Hence we should write the following code to log at the debug level:

if (logger.isDebugEnabled) logger.debug(s"Some ${expensiveExpression} message!")

This is even true in the presence of parameterized log methods like available for Logback, at least if readability matters:

if (logger.isDebugEnabled) logger.debug("Some {} message!", expensiveExpression)

Yet this idiom is too heavyweight, so that many of us just omit the isEnabled-check. Fortunately Scala macros can be used to make our lives easier: ScalaLogging offers the class Logger with lightweight logging methods that will be expanded to the above idiom. So all we have to write is:

logger.debug(s"Some ${expensiveExpression} message!")

After the macro has been applied, the code will have been transformed into the above described idiom.

In addition ScalaLogging offers the trait Logging which conveniently provides a Logger instance initialized with the name of the class mixed into:

class MyClass extends Logging {
  logger.debug("This is very convenient ;-)")


  • Scala 2.10.0
  • SLF4J 1.7.2 or Log4j 2.0-beta3

Using ScalaLogging

ScalaLogging is published to the Sonatype OSS snapshot and release repositories. As the Sonatype OSS release repository is mirrored to Maven Central (with a certain delay), you can use releases without adding custom resolvers to your sbt build definition or custom repositories to your Maven POM. The group id (organization) is com.typesafe and the artifact ids (names) are scalalogging-slf4j and scalalogging-log4j.

The following example shows how to add a dependency to the latest release version of ScalaLogging to your sbt (0.12.x) build definition:

libraryDependencies += "com.typesafe" %% "scalalogging-slf4j" % "1.0.1"

The following example shows how to add a dependency to the latest snapshot version of ScalaLogging to your sbt (0.12.x) build definition:

resolvers += Opts.resolver.sonatypeSnapshots

libraryDependencies += "com.typesafe" %% "scalalogging-log4j" % "1.1.0-SNAPSHOT"

Contribution policy

Contributions via GitHub pull requests are gladly accepted from their original author. Before we can accept pull requests, you will need to agree to the Typesafe Contributor License Agreement online, using your GitHub account.


This code is open source software licensed under the Apache 2.0 License.

Something went wrong with that request. Please try again.