我在解决方案中有包含其他类库的 WCF 项目。我使用 nuget 包管理器为需要日志记录的项目添加了 Common.Logging。
我收到此错误:
无法创建类型
'Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter,
Common.Logging.Log4Net'
当我执行时:
Common.Logging.ILog logger = Common.Logging.LogManager.GetLogger<Service1>();
logger.Error("Test");
我的 Web.Config 是here https://gist.github.com/divsoft/169ebb487420ff1290ce
EDIT :
Bin Folder have Common.Logging.Log4net1213.dll as well as log4net.dll
检查 Common.Logging.Log4net.dll 是否已复制到输出目录。在大多数情况下,dll 丢失是因为项目中没有直接引用。
在你的配置中你有:
<logging>
<factoryAdapter type="Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter, Common.Logging.Log4Net">
<arg key="configType" value="INLINE" />
</factoryAdapter>
</logging>
Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter、Common.Logging.Log4Net -> 引用不在您的目录中的 Common.Logging.Log4Net.dll。有一个Common.Logging.Log4Net1213.dll dll。所以你可以将配置更改为:
<logging>
<factoryAdapter type="Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter, Common.Logging.Log4Net1213">
<arg key="configType" value="INLINE" />
</factoryAdapter>
</logging>
或者重命名dll
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)