无法在Log4j-core 2.3上解析BasicConfigurator类

时间:2015-07-12 14:15:38

标签: apache selenium log4j webdriver

我正在尝试在我的selenium测试中使用log4j,我使用maven在我的项目中导入log4j。通过访问mvnrepository.com我搜索了apache log4j并在我的项目中添加了Apache log4j 1.2.17但是显示了大约50个工件缺失错误。我检查了mvnrepository,它注意到log4j 1.2.17被移动到New Group:org.apache.logging.log4j和New Artifact:log4j-core。

我在maven项目中添加了Log4j-core 2.3依赖项,但无法解析BasicConfigurator类。我搜索Log4j-core 2.3的类列表,发现BasicConfigurator类不是包的一部分。只有Log4j 1.2.17才有这个类。

如何在maven项目中成功导入BasicConfigurator类?我需要什么依赖?

谢谢!

1 个答案:

答案 0 :(得分:0)

这将适用于 log4j2- ConfigurationSource configSource = new ConfigurationSource(logConfigurationStream); Configurator.initialize(null, configSource);

或者您可以通过以下方式设置配置位置来使用 Logger 上下文 - LoggerContext context = (LoggerContext)LogManager.getContext(false); context.setConfigLocation(new File(//log4j2.xmlPath).toURI());