gpt4 book ai didi

spring - Spring Yaml动态变量替换

转载 作者:行者123 更新时间:2023-12-03 03:22:16 29 4
gpt4 key购买 nike

我的log4j2.yml配置文件出现问题-以下配置未按预期工作:

  fileName: "${baseName}/logs/${project.build.finalName}.log"
filePattern: "${baseName}/logs/%d{yyyy-MM-dd}_${project.build.finalName}.log.gz"

变量$ {baseName}已在application.properties文件中声明:
baseName="d:\dev\dd"
通过build.gradle文件中的以下依赖项添加了yaml支持:
compile "com.fasterxml.jackson.core:jackson-core"
compile "com.fasterxml.jackson.dataformat:jackson-dataformat-yaml"

在构建项目时,我在项目根目录中有一个$ {baseName}目录。由于某些原因,未将值“d:\ dev \ dd”分配给$ {baseName}变量。

有什么想法如何处理吗?

最佳答案

变量应在log4j2.yaml中设置为properties.property,例如:

Configuration:
properties:
property:
- name: baseName
value: /home/shared/log/
- name: filename
value: sample.log
- name: pattern
value: "%d{yyyy-MM-dd HH:mm:ss} [%p] [%t] [%c] %m%n"
status: INFO
Appenders:
Console:
name: console
target: SYSTEM_OUT
PatternLayout:
pattern: "${pattern}"
RollingFile:
- name: FileAppender
fileName: "${baseName}${filename}"
filePattern: "${baseName}${filename}-%d{yyyy-MM-dd}"
PatternLayout:
pattern: "${pattern}"
Policies:
TimeBasedTriggeringPolicy: {}
Loggers:
Root:
level: INFO
AppenderRef:
- ref: console
- ref: FileAppender

关于spring - Spring Yaml动态变量替换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32832051/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com