Skip to content

Instantly share code, notes, and snippets.

Last active January 23, 2018 17:23
What would you like to do?
Supports tracer bullet dynamic logging
package controllers
import javax.inject._
import play.api.mvc._
class TracerBulletController @Inject() extends Controller {
private val logger = org.slf4j.LoggerFactory.getLogger("application")
<turboFilter class="ch.qos.logback.classic.turbo.MarkerFilter">
private val tracerMarker = org.slf4j.MarkerFactory.getMarker("TRACER")
def generateMarker(implicit request: RequestHeader): org.slf4j.Marker = {
// You can return null here, but I prefer to at least have a base do-nothing marker...
val marker = org.slf4j.MarkerFactory.getDetachedMarker("dynamic")
request match {
case r if r.getQueryString("trace").nonEmpty =>
case other =>
def index = Action { implicit request =>
val marker = generateMarker
if (logger.isTraceEnabled(marker)) {
logger.trace(marker, "Hello world!")
Ok("hello world")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment