Unable to create type 'Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter, Common.Logging.Log4Net'

浪子不回头ぞ 提交于 2020-01-24 05:47:05

问题


I have WCF project with other class libraries in a solution. I added Common.Logging using nuget package manager for projects which require logging.

I am getting this error :

Unable to create type 'Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter, Common.Logging.Log4Net'

when I excute :

Common.Logging.ILog logger = Common.Logging.LogManager.GetLogger<Service1>();
logger.Error("Test");

My Web.Config is here

EDIT : Bin Folder have Common.Logging.Log4net1213.dll as well as log4net.dll


回答1:


Check if your Common.Logging.Log4net.dll is copied to your output directory. In most cases the dll is missing because there is no direct reference in the project.

In your config you have:

<logging>

  <factoryAdapter type="Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter, Common.Logging.Log4Net">

    <arg key="configType" value="INLINE" />

  </factoryAdapter>

</logging>

Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter, Common.Logging.Log4Net -> references the Common.Logging.Log4Net.dll which is not in your directory. There is a Common.Logging.Log4Net1213.dll dll. So you can change the config to:

<logging>

  <factoryAdapter type="Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter, Common.Logging.Log4Net1213">

    <arg key="configType" value="INLINE" />

  </factoryAdapter>

</logging>

Or rename the dll



来源:https://stackoverflow.com/questions/30595476/unable-to-create-type-common-logging-log4net-log4netloggerfactoryadapter-commo

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!