Skip to content

Instantly share code, notes, and snippets.

@ephemeralsnow
Created April 5, 2015 05:48
Show Gist options
  • Save ephemeralsnow/d43e3d870543338b28fd to your computer and use it in GitHub Desktop.
Save ephemeralsnow/d43e3d870543338b28fd to your computer and use it in GitHub Desktop.
SLF4J/LogbackでJSON形式のログ出力 ref: http://qiita.com/ephemeralsnow/items/10d362286aaa55120822
libraryDependencies ++= Seq(
"org.slf4j" % "slf4j-api" % "1.7.12",
"ch.qos.logback" % "logback-core" % "1.1.3",
"ch.qos.logback" % "logback-classic" % "1.1.3",
"ch.qos.logback.contrib" % "logback-json-core" % "0.1.2",
"ch.qos.logback.contrib" % "logback-json-classic" % "0.1.2",
"ch.qos.logback.contrib" % "logback-jackson" % "0.1.2",
"com.fasterxml.jackson.core" % "jackson-core" % "2.5.2",
"com.fasterxml.jackson.core" % "jackson-databind" % "2.5.2",
"com.fasterxml.jackson.core" % "jackson-annotations" % "2.5.2"
)
<property name="MONITORING_LOG" value="${LOG_DIR}/monitoring.log" />
<appender name="FILE_MONITORING" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${MONITORING_LOG}</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${MONITORING_LOG}.%d.gz</fileNamePattern>
<maxHistory>14</maxHistory>
</rollingPolicy>
<encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
<layout class="ch.qos.logback.contrib.json.classic.JsonLayout">
<jsonFormatter class="ch.qos.logback.contrib.jackson.JacksonJsonFormatter">
<!-- <prettyPrint>true</prettyPrint> -->
</jsonFormatter>
<timestampFormat>yyyy-MM-dd'T'HH:mm:ss.SSSXXX</timestampFormat>
<includeContextName>false</includeContextName>
<appendLineSeparator>true</appendLineSeparator>
</layout>
<charset>UTF-8</charset>
</encoder>
</appender>
<root level="INFO">
<appender-ref ref="FILE_MONITORING" />
</root>
{"timestamp":"2015-04-05T14:45:28.481+09:00","level":"WARN","thread":"pool-1-thread-1-ScalaTest-running-SQSHelperSpec","logger":"helpers.aws.sqs.SQSHelperSpec","message":"com.amazonaws.AmazonClientException: Unable to load AWS credentials from any provider in the chain"}
{"timestamp":"2015-04-05T14:45:31.526+09:00","level":"WARN","thread":"pool-1-thread-1-ScalaTest-running-SQSHelperSpec","logger":"helpers.aws.sqs.SQSHelperSpec","message":"com.amazonaws.AmazonClientException: Unable to load AWS credentials from any provider in the chain"}
{"timestamp":"2015-04-05T14:45:31.775+09:00","level":"WARN","thread":"pool-1-thread-1-ScalaTest-running-SQSHelperSpec","logger":"helpers.aws.sqs.SQSHelperSpec","message":"com.amazonaws.AmazonClientException: Unable to load AWS credentials from any provider in the chain"}
{"timestamp":"2015-04-05T14:45:31.864+09:00","level":"WARN","thread":"pool-1-thread-1-ScalaTest-running-SQSHelperSpec","logger":"helpers.aws.sqs.SQSHelperSpec","message":"com.amazonaws.AmazonClientException: Unable to load AWS credentials from any provider in the chain"}
<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.12</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>1.1.3</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.1.3</version>
</dependency>
<dependency>
<groupId>ch.qos.logback.contrib</groupId>
<artifactId>logback-json-core</artifactId>
<version>0.1.2</version>
</dependency>
<dependency>
<groupId>ch.qos.logback.contrib</groupId>
<artifactId>logback-json-classic</artifactId>
<version>0.1.2</version>
</dependency>
<dependency>
<groupId>ch.qos.logback.contrib</groupId>
<artifactId>logback-jackson</artifactId>
<version>0.1.2</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.5.2</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.5.2</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.5.2</version>
</dependency>
</dependencies>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment