java如何从现有lo4j2加载属性名。xml编程
是否有任何方法可以通过编程方式获得log4j2中配置的properties
。xml。
例如:我想获得下面示例文件中提到的basePath属性的值:
<Configuration status="warn">
<Properties>
<Property name="basePath">C:/Users/App/logs
</Property>
</Properties>
<Appenders>
.
.
.
</Appenders>
我检查了配置对象,但找不到任何内容。下面是一个示例代码:
public static void initLogFile(String path, Level level) {
final LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
final Configuration config = ctx.getConfiguration();
}
我能得到这房子吗?提前谢谢
# 1 楼答案
你试过了吗
?