[英]Logs are not printing
我目前正在研究一個使用了彈簧的項目。 對於Junit,我正在使用@RunWith(SpringJUnit4ClassRunner.class)批注。 一切正常,除非我看不到任何用於applicationContext的春季處理的日志。 在控制台窗口中,這是當前消息:
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.
我將log4j.properties保留在Eclipse的src / main / resources文件夾中(使用maven項目)。 以下是內容:
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
研究了關於類似問題的已提出的問題。 但是仍然沒有什么問題的線索。 這里有人可以幫我嗎?
謝謝
您需要指定將log4j屬性存儲為spring應用程序的上下文參數的位置。 您可以通過在web.xml中添加以下部分來完成。 確保將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.