[英]Logging Spring bean creation / dependency injection
I'm looking for a way to set up Log4j
(or any other logger) so that I can see in log whenever Spring creates a bean or sets a bean property.我正在寻找一种设置Log4j
(或任何其他记录器)的方法,以便在 Spring 创建 bean 或设置 bean 属性时可以在日志中看到。 Eg.例如。 something like this:像这样的东西:
1:00:00 Creating bean Foo (Foo@ef5c94)
1:00:01 Creating bean Bar (Bar@147a87e)
1:00:02 Setting bean Foo (Foo@ef5c94) to Bar (Bar@147a87e)
(...)
Is this easily possible?这很容易吗? I'm using Spring 2.5.6
(no choice there:/ ) and Log4j
(version doesn't matter I expect).我正在使用Spring 2.5.6
(没有选择:/)和Log4j
(我期望的版本无关紧要)。
Looks like org.springframework.beans.factory.support.DefaultListableBeanFactory
logger is the best you can get.看起来org.springframework.beans.factory.support.DefaultListableBeanFactory
记录器是你能得到的最好的。
Also simply try turning on ALL logging level for the whole org.springframework
- maybe you'll find something more useful.也可以简单地尝试为整个org.springframework
打开所有日志记录级别——也许你会发现一些更有用的东西。
You can use a Log4jConfigListener in your web.xml:您可以在 web.xml 中使用 Log4jConfigListener:
http://cristianvrabie.blogspot.com/2008/09/spring-commonslogging-and-log4j.html http://cristianvrabie.blogspot.com/2008/09/spring-commonslogging-and-log4j.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.