Skip to content

Commit

Permalink
Use structured log format in production by default
Browse files Browse the repository at this point in the history
  • Loading branch information
akobor committed Aug 11, 2020
1 parent a9aca37 commit 1ec1562
Showing 1 changed file with 22 additions and 14 deletions.
36 changes: 22 additions & 14 deletions src/main/resources/logback.xml
Original file line number Diff line number Diff line change
@@ -1,20 +1,28 @@
<configuration>
<variable name="communicationLogLevel" value="${HTTP_COMMUNICATION_LOG_LEVEL:-INFO}"/>

<!-- GCP's structured log format-->
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<if condition='property("LOG_FORMAT").equals("JSON")'>
<then>
<encoder class="net.logstash.logback.encoder.LogstashEncoder"/>
</then>
<else>
<withJansi>true</withJansi>
<encoder>
<pattern>
%cyan(%d{HH:mm:ss.SSS}) %gray([%thread]) %highlight(%-5level) %magenta(%logger{36}) - %msg%n
</pattern>
</encoder>
</else>
</if>
<encoder class="net.logstash.logback.encoder.LoggingEventCompositeJsonEncoder">
<providers>
<timestamp>
<fieldName>timestamp</fieldName>
</timestamp>
<loggerName/>
<logLevel>
<fieldName>severity</fieldName>
</logLevel>
<message/>
<stackHash/>
<stackTrace>
<throwableConverter class="net.logstash.logback.stacktrace.ShortenedThrowableConverter">
<maxDepthPerThrowable>30</maxDepthPerThrowable>
<maxLength>2048</maxLength>
<shortenedClassNameLength>20</shortenedClassNameLength>
<rootCauseFirst>true</rootCauseFirst>
</throwableConverter>
</stackTrace>
</providers>
</encoder>
</appender>

<logger name="org.jooq" level="ERROR"/>
Expand Down

0 comments on commit 1ec1562

Please sign in to comment.