如何在类路径中将abc.properties设置为log4j2 configuartion文件

时间:2018-03-26 12:54:53

标签: log4j2

我正在从log4j1迁移到log4j2,我的文件名为abc.properties,我需要在classpath中设置为log4j配置文件。我试过了 -Dlog4j.configurationFile = abc.properties,但没有用?有人可以帮忙吗?

1 个答案:

答案 0 :(得分:0)

如果文件在classpath上,您可以在代码中设置位置 -

org.apache.logging.log4j.core.config.Configurator.initialize(null, "abc.properties");

在使用Logger之前使用上述语句设置文件路径。

相关问题