petterarvidsson / slime   0.2.1


Structured Logging for Scala

Scala versions: 2.12


slime is a structured logging library for Scala. It is based on logback and provides a custom type-based logger interface plus encoders.


Configuration is made through the same mechanisms made available by logback. For instance, you can use logback.xml to enable slime:

<?xml version="1.0" encoding="UTF-8"?>

  <appender name="console" class="ch.qos.logback.core.ConsoleAppender">
    <encoder class="com.unstablebuild.slime.Encoder" />
      <format class="com.unstablebuild.slime.format.Json" />

  <root level="all">
    <appender-ref ref="console" />


... then, given a piece of code like the one below:

case class User(username: String, emails: Set[String])

class Service extends LazyLogging {

  def register(user: User): Unit = {
    val id = //.."A new user was registered", "id" -> id, "user" -> user)


... would generate the following output:

{"level":"INFO","message":"A new user was registered","id":123,"user":{"username":"slimedoe","emails":["[email protected]"]}}