记录Spring bean创建/依赖注入

Ond*_*cka 9 java spring dependency-injection log4j

我正在寻找一种设置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)
(...)
Run Code Online (Sandbox Code Playgroud)

这很容易吗?我正在使用Spring 2.5.6(没有选择:/)和Log4j(版本并不重要,我期待).

Tom*_*icz 6

看起来像org.springframework.beans.factory.support.DefaultListableBeanFactorylogger是你能得到的最好的.

还只是尝试打开所有日志记录级别为全org.springframework-也许你会发现更多的东西有用.