Recently, I used the ILog interface of Common. Logging as a log interface. At the same time, I used its log4net adapter and log4net recorder to record system logs. I encountered a log4net version problem during use.
Install the package in project component management:
PM> Install-Package Common. Logging
PM> Install-Package Common. Logging. Log4Net [2.0.1 version; dependent on Common. Logging (≥2.0.0); log4net (= 1.2.10 )]
Log4net. the dll version is 1.2.10.0. In this matching version, the following error occurs: {"Unable to create type' Common. logging. log4Net. log4NetLoggerFactoryAdapter, Common. logging. log4net '"}
An error occurred while upgrading the log4net component to the latest version 1.2.13. Install-Package: An error occurred while updating "log4net 1.2.10" to "log4net 2.0.3. "Common. Logging. log4net" compatible with "Log4Net 2.0.3" cannot be found.
Delete Common. Logging. Log4Net and reinstall the following versions.
PM> Install-Package Common. Logging. Log4Net1211 [2.2.0 version; Common. Logging (≥2.0.0); Log4Net (≥1.2.11 )]
In the project, the log4net. dll version is 1.2.11.0, run OK, upgrade log4net1.2.13, and run OK;
Note the differences in assembly file names in the configuration file
Version redirection
This is mainly because log4net version 1.2.11 is different from the publicKeyToken of 1.2.10. You can use the VS tool SN-T component file name. dll to view the public key.
The public key of log4net (≥1.2.11) is marked as 669e0ddf0bb1aa2a
The public key of log4net (= 1.2.10) is marked as 1b44e1d1_115821.
Http://www.nuget.org/packages/Log4Net/
Http://www.nuget.org/packages/Common.Logging/
Http://www.nuget.org/packages/Common.Logging.Log4Net1211/
Http://www.nuget.org/packages/Common.Logging.Log4Net/
Http://developer.3l.nl/post/16463925249/log4net-1-2-11-dependency-hell