问题描述
我想将 ILog 注入我的类,而不是 ILoggerFactoryAdapter,但 ILoggerFactoryAdapter 需要调用类的名称(想要记录某些内容的类,因此我可以正确分类)所以 Autofac 可以以某种方式识别类哪些是请求 ILog 并从工厂自动创建 ILog?
I would like to inject ILog into my classes, not an ILoggerFactoryAdapter, but the ILoggerFactoryAdapter needs the name of the calling class (the class that wants to log something, so i can be properly categorized) so can Autofac somehow identify the class which are requesting the ILog and automaticly create the ILog from the factory?
推荐答案
Bailey Ling 提出了一个很好的方法,它不使用堆栈遍历 - 请参阅此处的帖子:http://groups.google.com/group/autofac/msg/704f926779cbe8b3
Bailey Ling came up with a great approach that doesn't use stack walking - see post here: http://groups.google.com/group/autofac/msg/704f926779cbe8b3
这篇关于带有 Common.Logging 和 Autofac 的自动工厂?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!