【问题标题】:Spring boot: How to pass variable from application-env.properties to another properties file?Spring boot:如何将变量从 application-env.properties 传递到另一个属性文件?
【发布时间】:2017-01-20 17:34:24
【问题描述】:

我在 Spring Boot 中有 application-local.properties 和 application-dev.properties,其值如下:
logging.level.file=INFO

在另一个属性文件 log4j.properties 中,我想根据我的运行环境获取上述值。我尝试使用
${logging.level.file}
,但我没有得到它(空字符串)。

我该怎么做?

【问题讨论】:

  • 你能详细说明为什么你需要这样做吗?最终目标是什么?如果你能说出这一点,可能会有更好的方法。
  • 我的目标是为不同的环境设置不同的日志级别,例如本地环境的DEBUG和开发环境的INFO。

标签: logging spring-boot log4j


【解决方案1】:

这并不容易。默认情况下,Spring-Boot 带有 Logback 配置。但是,也有可能激活 log4j,这在以下线程中进行了讨论:Log4j.properties in Spring boot

【讨论】:

    猜你喜欢
    • 2021-05-25
    • 2014-07-02
    • 1970-01-01
    • 2021-05-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-04-25
    • 2017-05-23
    相关资源
    最近更新 更多