在Spring中启用日志记录 [英] Enabling logging in Spring
本文介绍了在Spring中启用日志记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我们使用RAD 7.5作为IDE,并使用log4j进行日志记录。我们想启用春季记录。
We are using RAD 7.5 as IDE and also log4j for logging purpose. we want to enable spring logging.
我尝试了以下
- 已添加
org.springframework.web.util.Log4jConfigListener
作为web.xml
中的侦听器。它是在ContextLoaderListener
之前添加的。 -
log4j.properties
出现在应用程序中WEB-INF
下的战争。 - 在
web.xml中添加以下上下文参数
:
- Added
org.springframework.web.util.Log4jConfigListener
as a listener inweb.xml
. It is added beforeContextLoaderListener
. log4j.properties
is present in application war underWEB-INF
.- Add the following context parameter in
web.xml
:
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>/WEB-INF/log4j.properties</param-value>
</context-param>
在log 4j中添加以下内容
In log 4j added the following
log4j.logger.org.springframework=ALL
即便如此,我也无法在控制台或日志文件中看到任何输出。
Even then I am not able to see any output in console or in log file.
任何人都可以告诉我确切的步骤启用春季记录。
Can anyone please let me know the exact steps for enabling spring logging.
推荐答案
在您的属性文件中,您应该
In your properties file you should have
log4j.category.org.springframework=ALL
not
log4j.logger.org.springframework=ALL
参见 Spring节目中的这一部分。
这篇关于在Spring中启用日志记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文