struts2.5.20 解决not find a logging implementation. Please add log4j-core to the classpath问题
出现问题:
ERROR StatusLogger Log4j2 could not find a logging implementation. Please add log4j-core to the classpath. Using SimpleLogger to log to the console...
意思是
StatusLogger Log4j2找不到日志实现。请将log4j-core添加到类路径中。使用SimpleLogger登录控制台…
首先,我导入的是struts2.5.20的最小包
我们看到最小包中没有log4j-core-2.11.1.jar这个包,在struts中lib也没发现有。
那么我们可以去下载一个,下载链接http://www.apache.org/dyn/closer.lua/logging/log4j/2.11.1/apache-log4j-2.11.1-bin.zip
点击图中链接进行下载,解压下载的压缩包。
找到log4j-core-2.11.1.jar包,拷贝到项目的lib目录下
同时在项目的src下加入一个log4j2.xml 文件,配置如下:
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN">
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="%d{ABSOLUTE} %5p %c{1}:%L - %m%n" />
</Console>
<File name="LogFile" filename="e:/mylog.log">
<PatternLayout pattern="%d{ABSOLUTE} %5p %c{1}:%L - %m%n" />
</File>
</Appenders>
<Loggers>
<Root level="info">
<AppenderRef ref="Console" />
<!-- <AppenderRef ref="LogFile" /> -->
</Root>
</Loggers>
</Configuration>