Created
February 27, 2016 13:30
-
-
Save marcospereira/bd99429a4ee8811ae8b3 to your computer and use it in GitHub Desktop.
Play controller using a custom logger
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package controllers | |
import play.api.Logger | |
import play.api.mvc._ | |
class Application extends Controller { | |
lazy val logger = Logger(classOf[Application]) | |
def index = Action { implicit request => | |
logger.warn("See my message!") // [warn] - controllers.Application - 11 - See my message! | |
Ok(views.html.index("Your new application is ready.")) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<configuration> | |
<conversionRule conversionWord="coloredLevel" converterClass="play.api.Logger$ColoredLevel" /> | |
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> | |
<encoder> | |
<pattern>%coloredLevel - %logger - %line - %message%n%xException</pattern> | |
</encoder> | |
</appender> | |
<!-- | |
The logger name is typically the Java/Scala package name. | |
This configures the log level to log at for a package and its children packages. | |
--> | |
<logger name="play" level="INFO" /> | |
<logger name="application" level="DEBUG" /> | |
<root level="INFO"> | |
<appender-ref ref="STDOUT" /> | |
</root> | |
</configuration> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment