第一次使用Junit的时候出现错误:
ERROR StatusLogger Log4j2 could not find a logging implementation. Please add log4j-core to the classpath. Using SimpleLogger to log to the console...
开始是缺少log4j-core这个包(笔者用的是srtuts2自带的jar包,没有log4j-core.jar),官网下载,添加之后还是不行,报错:
ERROR StatusLogger No log4j2 configuration file found. Using default configuration: logging only errors to the console.
也就是找不到log4j2的配置文件,这下好了,彻底懵了,好在有万能的度娘,一番百度之后找到解决办法:
在src目录下添加log4j2.xml配置未见就可以了,具体如下(具内容配置官网上有,百度也可以,下面参考的也有):
<?xml version="1.0" encoding="UTF-8"?> <Configuration status="WARN"> <Appenders> <Console name="Console" target="SYSTEM_OUT"> <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/> </Console> </Appenders> <Loggers> <Root level="error"> <AppenderRef ref="Console"/> </Root> </Loggers> </Configuration>
问题就解决了,只是记录了自己犯的错误,同时提供参考,大神勿喷~
下面是笔者参考解决方案的原文
参考原文http://blog.csdn.net/qq_35302765/article/details/78125627