gpt4 book ai didi

java - 使用 apache commons-configuration PropertiesConfiguration 配置 java.util.logging?

转载 作者:行者123 更新时间:2023-12-01 13:57:49 26 4
gpt4 key购买 nike

我想加载属性文件和命令行参数,然后在运行时动态配置日志记录,我以前可以这样做:

Properties configuration;
...

ByteArrayOutputStream os = new ByteArrayOutputStream();
ByteArrayInputStream is;
byte[] buf;
try {
configuration.store(os, "logging");
buf = os.toByteArray();
is = new ByteArrayInputStream(buf);
java.util.logging.LogManager.getLogManager().readConfiguration(is);
} catch (IOException e) {
System.err.println("Failed to configure java.util.logging.LogManager");
}

使用 Properties 很好,但是可以使用 PropertiesConfiguration 来完成吗?

(仅供引用,我希望利用 commons-configuration 提供的属性数组)

最佳答案

使用ConfigurationConverter将 PropertiesConfiguration 转换为标准 poperties 文件

关于java - 使用 apache commons-configuration PropertiesConfiguration 配置 java.util.logging?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19531600/

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