Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Logback is unable to recognize variable substitution for scanPeriod properties

Tags:

java

logback

I am trying to use variable substitution for the scanPeriod property such that i can have multiple environment files.

It seems like Logback is unable to recognize variable substitution for certain properties.

For example the scanPeriod property:

Logback configuration:

<configuration scan="${scan:-true}" scanPeriod="${scan-interval:-10 minutes}">

Specified to take default value of 10 minutes of logback property is not defined.

Logback properties:

scan=true
scan-interval=30 seconds

This property should override the default configuration of 10 minutes.

Logback error:

java.lang.IllegalArgumentException: String value [${scan-interval:-10 minutes}] is not in the expected format.

According to the Duration API, the duration format is correct.

This is using:

  • slf4j 1.6.2
  • logback classis 0.9.30
  • logback core 0.9.30

EDIT: Filed a Jira report for this - http://jira.qos.ch/browse/LBCLASSIC-307

UPDATE: 28 Dec 2011 This is marked as a Major, and looked at by Ceki Gulcu. :D

UPDATE: 12 Jun 2012 Still no updates. Left comment in JIRA.

UPDATE: 12 July 2012 Accepted as a valid bug. To fix in 1.0.7

like image 733
Oh Chin Boon Avatar asked Nov 13 '11 04:11

Oh Chin Boon


1 Answers

According to the Duration API that you posted, you can also use (without the space):

<configuration scan="${scan:-true}" scanPeriod="${scan-interval:-10minutes}">

private static final Pattern DURATION_PATTERN = Pattern.compile(DOUBLE_PART
                              + "\\s*" + UNIT_PART, Pattern.CASE_INSENSITIVE);
like image 160
Matthew Farwell Avatar answered Oct 29 '22 14:10

Matthew Farwell