记录Spring bean创建/依赖注入 [英] Logging Spring bean creation / dependency injection
问题描述
我正在寻找一种设置 Log4j
(或任何其他记录器)的方式,以便在Spring创建一个bean或设置一个bean属性时,我可以在日志中看到。例如。如下所示:
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. 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)
(...)
这很容易吗?我使用 Spring 2.5.6
(没有选择:/)和 Log4j
(版本无关紧要期望)。
Is this easily possible? I'm using Spring 2.5.6
(no choice there :/ ) and Log4j
(version doesn't matter I expect).
推荐答案
看起来像 org.springframework.beans.factory.support.DefaultListableBeanFactory
logger是你可以得到的最好的。
Looks like org.springframework.beans.factory.support.DefaultListableBeanFactory
logger is the best you can get.
还可以尝试打开整个日志记录级别> org.springframework
- 也许你会发现更有用的东西。
Also simply try turning on ALL logging level for the whole org.springframework
- maybe you'll find something more useful.
这篇关于记录Spring bean创建/依赖注入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!