Myeclipse2014提示:ERROR StatusLogger Log4j2 could not find a logging implementation. Please add log4j
报错关键信息如下:
ERROR StatusLogger Log4j2 could not find a logging implementation. Please add log4j-core to the classpath. Using SimpleLogger to log to the console...
log4j:ERROR Could not find value for key log4j.appender.D
log4j:ERROR Could not instantiate appender named "D".
1.在启动Tomcat服务器时报错,在网上查找资料发现原来是少了一个配置文件导致,需要新建一个log4j2.xml文件。
2.可以在F:\MJWWorkspaces\SpringMVC_Spring_mybatis\WebRoot\WEB-INF\classes下添加一个log4j2.xml文件(路径参考自己项目的workspaces路径,具体操作可参考myeclipse→windows→preferences→general→startup and shutdown→workspaces→就可以找到项目路径);
添加log4j2.xml也可以在myeclipse上进行,右键项目名称→buildpath→configure build path→add folder,然后在XXX/webroot/web-inf/class 下添加log4j2.xml.
也可以在workspace路径下直接添加如下图操作:
log4j2.xml内容如下:
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="warn">
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="[%-5p] %d %c - %m%n" />
</Console>
<File name="File" fileName="dist/my.log">
<PatternLayout pattern="%m%n" />
</File>
</Appenders>
<Loggers>
<Logger name="mh.sample2.Log4jTest2" level="INFO">
<AppenderRef ref="File" />
</Logger>
<Root level="INFO">
<AppenderRef ref="Console" />
</Root>
</Loggers>
</Configuration>
3.然后重新启动服务。