Specify default value for a logback property, in spring-boot

In logback.xml or logback-spring.xml, you can set default value for both system property and project property (or you can say spring property).

1) For system property, you can simply go with the :- syntax. In the following example, the default level of ThresholdFilter is ERROR.

<configuration>

  <appender name="sentry" class="io.sentry.logback.SentryAppender">
    <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
      <level>${sentryLevel:-ERROR}</level>
    </filter>
  </appender>

</configuration>

You can override it by starting the java process with, such as -DsentryLevel=INFO.

2) For project property/spring property, you can set defaultValue in the springProperty element.

<configuration>

  <springProperty scope="context" name="sentryLevel" source="your.prop.path" defaultValue="ERROR"/>

  <appender name="sentry" class="io.sentry.logback.SentryAppender">
    <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
      <level>${sentryLevel}</level>
    </filter>
  </appender>

</configuration>

You can override it by changing the application.properties or application.yml.

your.prop.path=INFO

In logback.xml the correct separator is :-. More details in the logback docs.

In Spring the correct separator is : since Spring supports the ${my.property:defaultValue} syntax. More details in the PlaceholderConfigurerSupport doc.

So, when faced with a choice of default value separator for variable substitution the logback author(s) chose :- and the Spring author(s) chose :.