使用Common.Logging与log4net的组件版本兼容问题
引用:
近期使用了Common.Logging的ILog接口做日志接口,同时利用其log4net适配器与log4net记录器来记录系统日志,在使用过程中碰到了log4net版本问题。
项目组件管理中安装组件包:
PM> Install-Package Common.Logging
PM> Install-Package Common.Logging.Log4Net 【2.0.1版本;依赖Common.Logging (≥ 2.0.0); log4net (= 1.2.10)】
项目中将引用log4net.dll版本为 1.2.10.0,在此配套版本情况下,运行出现错误: {"Unable to create type 'Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter, Common.Logging.Log4Net'"}
也 将log4net组件升级到最新版本1.2.13失败,Install-Package : 将“log4net 1.2.10”更新到“log4net 2.0.3”失败。找不到与“log4net 2.0.3”兼容的“Common.Logging.Log4Net”版本。
将Common.Logging.Log4Net版本删除,重新安装以下版本
PM> Install-Package Common.Logging.Log4Net1211 【2.2.0版本;Common.Logging (≥ 2.0.0);Log4Net (≥ 1.2.11)】
项目中log4net.dll版本为 1.2.11.0, 运行OK,升级log4net1.2.13版本,升级成功,运行OK;
注意配置文件中程序集文件名差异
<common> <logging> <factoryAdapter type="Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter, Common.Logging.Log4Net1211">
版本重定向
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="Common.Logging" publicKeyToken="af08829b84f0328e" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-2.2.0.0" newVersion="2.2.0.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="log4net" publicKeyToken="669e0ddf0bb1aa2a" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-1.2.13.0" newVersion="1.2.13.0" /> </dependentAssembly> </assemblyBinding>
原因主要是由于log4net version 1.2.11与1.2.10的publicKeyToken不同所致。可利用VS工具SN –T 组件文件名.dll查看公钥。
log4net (≥ 1.2.11) 公钥标记为 669e0ddf0bb1aa2a
log4net (= 1.2.10) 公钥标记为 1b44e1d426115821
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
把项目做成了服务,结果怎么使用,都报错, 于是,直接在服务里,有添加"引用"了一边 3个DLL,才算是好使,
很纠结原因是什么...
使用Common.Logging与log4net的组件版本兼容问题的更多相关文章
- Net dll组件版本兼容问题
dll组件版本兼容问题,是生产开发中经常遇到的问题,常见组件兼容问题如:Newtonsoft.Json,log4net等 为了节约大家时间,想直接看解决方法的,可直接点击目录3.4 目录 1.版本兼容 ...
- Common.Logging log4net Common.Logging.Log4Net 配置
1.log4net 单独配置 log4net支持多种格式的日志输出,我这里只配置输出到本地的txt文件这种格式. <log4net> <root> <appender-r ...
- 基于Common.Logging + Log4Net实现的日志管理
前言 Common.Logging 是Commons-Logging(apache最早提供的日志门面接口,提供了简单的日志实现以及日志解耦功能) 项目的.net版本.其目的是为 "所有的.n ...
- 使用Common.Logging+log4net规范日志管理
Common.Logging+(log4net/NLog/) common logging是一个通用日志接口,log4net是一个强大的具体实现,也可以用其它不同的实现,如EntLib的日志.NLog ...
- 使用Common.Logging+log4net规范日志管理【转载】
使用Common.Logging+log4net规范日志管理 Common.Logging+(log4net/NLog/) common logging是一个通用日志接口,log4net是一个强大 ...
- Comon.Logging与Log4net联合使用
1.摘要 Common.Logging定义了一种接口的公共接口,尤其在Quartz.net中作为接口型的组件,而具体则使用log4net,nlog等组件. 2.使用步骤 Install-Package ...
- Net dll版本兼容问题
Net dll组件版本兼容问题 https://www.cnblogs.com/newP/p/9543528.html dll组件版本兼容问题,是生产开发中经常遇到的问题,常见组件兼容问题如:Newt ...
- Common.Logging源码解析一
Common.Logging是Apache下的一个开源日志接口组件,主要用于切换不同的日志库,因为当前流行的日志库有很多向log4j.log4net(log4j的.net版本)等等,所以为了能灵活的切 ...
- Common.Logging源码解析二
Common.Logging源码解析一分析了LogManager主入口的整个逻辑,其中第二步生成日志实例工厂类接口分析的很模糊,本随笔将会详细讲解整个日志实例工厂类接口的生成过程! (1).关于如何生 ...
随机推荐
- 常见dos命令
打开控制面板:win+r control 服务: win+r services.msc
- code style
http://www.jianshu.com/p/0a984f999592# https://github.com/drakeet/LayoutFormatter https://github.com ...
- Java继承多态中的方法访问权限控制
java中的方法天生具有继承多态特性,这点与C++有很大不同(需要在父类方发上加virtual关键字),但用起来确实方便了许多. 最简单的继承多态 声明一个接口BaseIF,只包含一个方法声明 pub ...
- 为XYplorer添加右键菜单:“使用XYplorer打开”
在目录.磁盘右键添加: Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\Directory\Shell\XYplorer]"E ...
- JavaScript——Cookie
JavaScript中的Cookie基础 页面用来保存信息的,比如登录.记住用户名. [cookie的特性] (1)同一个网站中所有页面共享一套cookie: (2)数量.大小有限: (3)有保质期, ...
- python变量与数据类型
变量 什么是变量 所谓变量,指的是在程序运行过程中需要用到的中间结果,变量定义后,会占用一块内存开辟的空间地址,通过内存空间确保同一时间的唯一性. >>> print(id.__do ...
- sql 根据字段查询不同表
SELECT snFundType,snBusinessType, THEN (select vcPaySerialNo from aa where vcSerialNo=a.vcRelationSe ...
- img的问题
一个div的宽高比和 里面的img的宽高比是一样的 ,div img { width:100%:height:100%;} img {border:0} img{ 设置为border:none无 ...
- asp.net通过配置文件设置默认页
<configuration> <system.webServer> <defaultDocument> <files> <clear /& ...
- JS预览图像将本地图片显示到浏览器上
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <hea ...