[英]Logs are not printing
I am currently working on a project which has spring used in it. 我目前正在研究一个使用了弹簧的项目。 For Junit, i am using @RunWith(SpringJUnit4ClassRunner.class) annotation.
对于Junit,我正在使用@RunWith(SpringJUnit4ClassRunner.class)批注。 Everything is working fine except I do not see any logs for spring processing of applicationContext.
一切正常,除非我看不到任何用于applicationContext的春季处理的日志。 In the console window, this is a current message :
在控制台窗口中,这是当前消息:
log4j:WARN No appenders could be found for logger (org.springframework.test.context.support.DefaultTestContextBootstrapper).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
I have kept the log4j.properties in src/main/resources folder of Eclipse(Using a maven project). 我将log4j.properties保留在Eclipse的src / main / resources文件夹中(使用maven项目)。 Following are the contents :
以下是内容:
Log4j.properties ; Log4j.properties;
# Root logger option
log4j.rootLogger=INFO
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%p\t%d{ISO8601}\t%r\t%c
\t[%t]\t%m%n
Have looked at already raised Q/A regarding similar issues. 研究了关于类似问题的已提出的问题。 But still no clue about what is the issue.
但是仍然没有什么问题的线索。 Could anyone here help me please in this ?
这里有人可以帮我吗?
Thanks 谢谢
You need to specify the where the log4j properties are stored as a context param of your spring application. 您需要指定将log4j属性存储为spring应用程序的上下文参数的位置。 You can done by adding the following part inside your web.xml.
您可以通过在web.xml中添加以下部分来完成。 Make sure you bundle log4j.properties file inside your /WEB-INF/classes/ directory.
确保将log4j.properties文件捆绑在/ WEB-INF / classes /目录中。
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>/WEB-INF/classes/log4j.properties</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.