Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

In spring-boot application, I am trying to config a default dir for logback.

Usually, in logback.xml I would config it this way:

<property name="logFile.dir" value="${catalina.home:-/tmp}/logs" />

The separator is :-.

But, in application.properties:

I have to config it this way:

logging.file=${catalina.home:/tmp}/logs/sportslight.log

Need to change the separator from :- to :.

The questions are:

  • In logback.xml, which is the correct separator, :- or :?
  • In application.properties, why only : works, is it because spring-boot would handle it first before pass the value to logback?
like image 731
user218867 Avatar asked Jul 12 '17 12:07

user218867


1 Answers

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 :.

like image 78
glytching Avatar answered Oct 19 '22 00:10

glytching