记录Spring bean创建/dependency injection
我正在寻找一种方法来设置Log4j
(或任何其他记录器),以便我可以在Spring创建bean或设置bean属性时在日志中看到。 例如。 像这样的东西:
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
(版本并不重要,我期待)。
看起来像org.springframework.beans.factory.support.DefaultListableBeanFactory
logger是你能得到的最好的。
还可以尝试打开整个org.springframework
所有日志记录级别 – 也许你会找到更有用的东西。
您可以在web.xml中使用Log4jConfigListener:
http://cristianvrabie.blogspot.com/2008/09/spring-commonslogging-and-log4j.html