Logback 无法识别 scanPeriod 属性的变量替换

发布于 2024-12-15 08:23:24 字数 1212 浏览 1 评论 0原文

我正在尝试使用 scanPeriod 属性的变量替换,以便我可以拥有多个环境文件。

Logback 似乎无法识别某些属性的变量替换

例如scanPeriod属性:

Logback配置:

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

指定取默认值10分钟logback属性未定义。

Logback 属性:

scan=true
scan-interval=30 seconds

此属性应覆盖 10 分钟的默认配置。

Logback错误:

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

根据Duration API,持续时间格式正确。

这是使用:

  • slf4j 1.6.2
  • logback classis 0.9.30
  • logback core 0.9.30

编辑:为此提交了 Jira 报告 - http://jira.qos.ch/browse/LBCLASSIC-307

更新: 2011 年 12 月 28 日这被标记为 Major,并由 Ceki Gulcu 进行查看。 :D

更新: 2012 年 6 月 12 日 仍然没有更新。在 JIRA 中留下评论。

更新: 2012 年 7 月 12 日被接受为有效错误。 1.0.7 中修复

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

口干舌燥 2024-12-22 08:23:24

根据您发布的 Duration API,您还可以使用(没有空格):

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

private static final Pattern DURATION_PATTERN = Pattern.compile(DOUBLE_PART
                              + "\\s*" + UNIT_PART, Pattern.CASE_INSENSITIVE);

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);
月亮邮递员 2024-12-22 08:23:24

http://jira.qos.ch/browse/LOGBACK-396

接受为有效bug并在1.0.7中修复

http://jira.qos.ch/browse/LOGBACK-396

Accepted as a valid bug and to be fixed in 1.0.7

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文