Skip to content

Instantly share code, notes, and snippets.

@stokito
Created August 14, 2019 22:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stokito/a06b093d9798f125d7a29eb1c2d26caf to your computer and use it in GitHub Desktop.
Save stokito/a06b093d9798f125d7a29eb1c2d26caf to your computer and use it in GitHub Desktop.
Get rid off Janino condition tags for the pattern and simplify it with variable reference The <if> tag requires the Janino library with full java compiler while we just need a simple pattern matching by env var. The solution is to declare two <property> constants with the pattern and then chose one of the constants as a pattern. If SINGLE_LINE_P…
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<include resource="org/springframework/boot/logging/logback/defaults.xml"/>
<property scope="context" name="pattern.singleLine.true" value="%d{yyyy-MM-dd'T'HH:mm:ss.SSS'Z', UTC} %5p %logger [%t] \(%X{trace}\) %X{loggingMessageExtender}: %replace(%m%n%ex){'\n(?=[^$])','\\n'}%nopex" />
<property scope="context" name="pattern.singleLine.false" value="%d{yyyy-MM-dd'T'HH:mm:ss.SSS'Z', UTC} -%5p %logger [%t] \(%X{trace}\) %X{loggingMessageExtender}: %m%n" />
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<Pattern>${pattern.singleLine.${SINGLE_LINE_PATTERN:-false}}"</Pattern>
</encoder>
</appender>
<root level="INFO">
<appender-ref ref="CONSOLE"/>
</root>
</configuration>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment