Skip to content

Latest commit

 

History

History
33 lines (29 loc) · 1.02 KB

README.md

File metadata and controls

33 lines (29 loc) · 1.02 KB

Logback Gaffer - Sift

Since the official support is dropped in version 1.0.12, this project extends Logback Gaffer so that SiftingAppender can be configured in Groovy DSL, e.g.:

import ch.qos.logback.classic.sift.SiftingAppender
import ch.qos.logback.classic.sift.MDCBasedDiscriminator
import ch.qos.logback.classic.PatternLayout

appender("SIFT", SiftingAppender) {
  discriminator(MDCBasedDiscriminator) {
    key = "userid"
    defaultValue = "unknown"
  }
  sift {
    appender("FILE-${userid}", FileAppender) {
      file = "${userid}.log"
      append = false
      layout(PatternLayout) {
        pattern = "%d [%thread] %level %mdc %logger{35} - %msg%n"
      }
    }
  }
}

root(DEBUG, ["SIFT"])

Usage instruction

  1. Build or download the jar for this project.
  2. Put it where you put logback-classic-$VERSION.jar.
  3. Done!