hmrc / play-json-logger   3.1.0-0-g0000000

Apache License 2.0 GitHub

DEPRECATED - Json logger encoder for Play applications

Scala versions: 2.11

DEPRECATED

Use https://github.com/hmrc/logback-json-logger instead

play-json-logger

Build Status Download

This is a Json encoder for Play applications logger. It uses MDC to output all its properties in the log message too.

These are the properties (for your application.conf) that you can use to alter the log output:

appName = MyApplication
logger.json.dateformat = yyyy-MM-dd HH:mm:ss.SSSZZ

You can then use the encoder in your logger configuration.

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

    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
        <encoder class="uk.gov.hmrc.play.logging.JsonEncoder"/>
    </appender>

    <logger name="uk.gov" level="DEBUG"/>

    <root level="INFO">
        <appender-ref ref="STDOUT"/>
    </root>
</configuration>

Adding to your service

Include the following dependency in your SBT build

resolvers += Resolver.bintrayRepo("hmrc", "releases")

libraryDependencies += "uk.gov.hmrc" %% "play-json-logger" % "[INSERT_VERSION]"

Use version >=1.0.0 for Java 7 & Play 2.3.x

License

This code is open source software licensed under the Apache 2.0 License.