Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Play framework logging setup, for getting proper class names into log files.
<conversionRule conversionWord="coloredLevel" converterClass="play.api.Logger$ColoredLevel" />
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level [%thread] %logger{36} - %message%n%xException</pattern>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<pattern>%coloredLevel %logger{15} - %message%n%xException{5}</pattern>
<logger name="play" level="INFO" />
<logger name="application" level="INFO" />
<logger name="controllers" level="INFO" />
<logger name="com.example.myapp" level="INFO" />
<root level="ERROR">
<appender-ref ref="STDOUT" />
<appender-ref ref="FILE" />
package controllers
import play.api._
import play.api.mvc._
object Application extends Controller with LoggerSupport {
def index = Action { implicit req =>"Serving index to ${req.remoteAddress}")
package controllers
trait LoggerSupport { self =>
implicit lazy val logger =
play.api.Logger(self.getClass.getName.replaceAll("\\$$", ""))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.