使用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).关于如何生 ...
随机推荐
- 如何修改tomcat后台console标题(转)
一个机器启动多个tomcat之后,分不清楚项目之间的区别,通过console口设置一下标题 tomcat控制台改名,修改方法: 1.找到tomcat\bin\catalina.bat 2.找到 ...
- 关于scanf的返回值
今天写一个小程序时误用while(scanf("%d",&b)!=a),以为scanf的返回值就是输入的值. 其实真相是: scanf返回接收到的变量值的个数. int a ...
- 一个JQuery发送ajax请求
环境: 1.jQuery v2.1.1 2.ThinkPHP 3.2.3 HTML页面: <button type="button" id="cat" o ...
- Boolean对象 识记
Boolean 对象表示两个值:"true" 或 "false". 1.创建 new Boolean(value); //构造函数 返回 对象+返回值 Bool ...
- 使用Interface创建的装饰者实现了必需的方法
很多开发团队也越来越认识到,自动化测试和持续部署可帮助开发团队提高迭代效率和质量.必须要有一份拿的出手的技术.社会不比在学校,上课随便听听,通过考试就行了,实在不行还有补考.在公司里,不是这样的. 正 ...
- Android编程获取手机的IMEI
手机在生产时,每部手机均有一个唯一的标识(ID),国际上采用国际移动设备身份码(IMEI, International Mobile Equipment Identity).IMEI是由15位数字组成 ...
- python之~ 序列化与反序列化
sy1.proto文件 syntax = "proto2"; message stuff { required int32 stuff_ID = ; required ; opti ...
- 查询被收录页面中的死链接 By SEO
朋友说他的站挂了,想知道被收录的页面有多少是死链,于是我就想了一下流程,从Site获得收录数量当然是不精准的,不过也没有更好的地了,真实的收录只有搜索引擎数据库里面才有... 查询被收录页面的状态码, ...
- <?php function say() { echo 'hello world'; } //在这里调用函数 say(); php 调用方法say()
<?php function say() { echo 'hello world'; } //在这里调用函数 say(); php 调用方法say()
- PHP截取中文字符串方法总结
<?php @header('Content-type: text/html; charset=UTF-8'); $arr = "sa撒的发dfa多少sfd看sdf得12上24飞452 ...