Logging和Autofac的自动工厂

Logging和Autofac的自动工厂

本文介绍了具有Common.Logging和Autofac的自动工厂?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将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的自动工厂?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 21:31