Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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 Snapshot of Bin Folder content related to Common.Logging

like image 792
Divesh Pal Avatar asked Feb 09 '23 23:02

Divesh Pal


1 Answers

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

like image 71
Peter Avatar answered Feb 14 '23 10:02

Peter