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

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

I am getting this error:

Cannot create type "Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter, Common.Logging.Log4Net

when I exhume:

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

      

My Web.Config here

EDIT: Bin Folder has Common.Logging.Log4net1213.dll as well as log4net.dll Snapshot of Bin Folder content related to Common.Logging

+4


source to share


2 answers


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

In your configuration, you:

<logging>

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

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

  </factoryAdapter>

</logging>

      



Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter, Common.Logging.Log4Net -> refers to Common.Logging.Log4Net.dll which is not in your directory. There is a DLL Common.Logging.Log4Net1213.dll. Therefore, 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 dll

+8


source


I also faced the same problem. Since the version of the log4net.dll file in the bin file is not V1.2.10.0. And my mistake is detailed.



Common.Logging.ConfigurationException: Unable to create instance of type 
Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter. 
Possible explanation is lack of zero arg and single arg Common.Logging.Configuration.NameValueCollection constructors 
---> System.IO.FileLoadException: Could not load file or assembly'log4net, version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821'; or one of its dependencies. The located assembly manifest definition  does not match the assembly reference. 

      

0


source







All Articles