ERROR StatusLogger Log4j2无法找到日志实现

14 浏览
0 Comments

ERROR StatusLogger Log4j2无法找到日志实现

我正在尝试实现log4j 2,但它一直抛出以下错误。

错误状态记录器(Log4j2)找不到日志实现。

请将log4j-core添加到类路径中,使用SimpleLogger将日志记录到控制台...

错误LogExample:将会打印此错误信息

严重错误LogExample:将会打印此严重错误信息

我尝试了网上给出的解决方案,但对我来说似乎不起作用。

这是我正在尝试运行的代码。

包demo;

导入org.apache.logging.log4j.LogManager;

导入org.apache.logging.log4j.Logger;

公共类LogExample {

private static final Logger LOG = LogManager.getLogger(LogExample.class);

公共静态无返回值main(String[] args) {

LOG.debug("This Will Be Printed On Debug");

LOG.info("This Will Be Printed On Info");

LOG.warn("This Will Be Printed On Warn");

LOG.error("This Will Be Printed On Error");

LOG.fatal("This Will Be Printed On Fatal");

LOG.info("Appending string: {}.", "Hello, World");

}

}

在pom.xml中添加的项目和依赖项:

[图片链接1]

[图片链接2]

感谢任何帮助。

0