Spring.net可以记录它作为构造函数对象做什么吗?
无论如何,是否有spring.net来记录它在构造对象时在做什么? 我需要在我的应用程序中
Constructing Object A
Constructing Object B
etc etc.....
解决循环依赖性,并且看到春季创建对象的顺序可能是巨大的帮助。
Is there anyway to get Spring.Net to log what it's doing as it constructs objects? Something on the order of
Constructing Object A
Constructing Object B
etc etc.....
I need to resolve a circular dependency within my application, and seeing the order in which Spring is creating the objects could be a huge help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这很容易做到。春季使用
concom.logging
。您可以从spring.objects.factory中获取记录输出。
请注意,您必须在
debug
级别上登录,这意味着您也会看到很多其他信息。以下app.config将使用log4net将CREATION调用记录到控制台:
因此,大多数是boiler-plate
common.logging
和log4net Configuration,该配置在common.logging
。如果要附加到文件或其他内容,请参见Log4net文档。This can easily be done. Spring uses
Common.Logging
. You can grab logging output fromSpring.Objects.Factory.*
classes and look for... Creating instance of Object 'your-id-here' ...
messages.Note that you have to log at
DEBUG
level, which means you'll see quite a lot of other information too.The following app.config would log creation calls to the console, using log4net:
So most of this is boiler-plate
Common.Logging
and log4net configuration, which is well documented on theCommon.Logging
website. If you want to append to a file or something else, see the log4net docs.