我想加载属性文件和命令行参数,然后在运行时动态配置日志记录,我以前可以这样做:
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/