maven 项目配置log4j

自己开始新建了一个maven项目,采用了druid+mybatis+spring mvc ,主要是为了测试使用druid,alibaba开源的数据库连接池

使用测试用例:

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath:application.xml" })

采用注解的方式使用SpringJunitTest

使用了log4j 打印日志,但是发现提醒:

log4j:WARN No appenders could be found for logger (org.springframework.test.context.junit4.SpringJUnit4ClassRunner).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.

经过搜索发现:需要将log4j.properties 文件放在项目

/src/main/resources

下,即将配置文件放在根目录下(http://stackoverflow.com/questions/4570072/how-to-configure-log4j-properties-for-springjunit4classrunner),

http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info

在里面可以看见相关FAQ:不提供默认配置文件
根据(http://blog.csdn.net/wuxinzaiyu/article/details/8524483)可以看到,还可以通过xml形式提供log4j配置文件,同样是直接放在项目 /src/main/resources 下
新建项目,遇到不少问题,记录一下。
posted @ 2015-10-09 17:12  轻言微雨  阅读(536)  评论(0)    收藏  举报