和netframework不一样的是,netcore 没有assembly文件。所以配置的时候需要注意:

1.配置文件可以没有

<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
</configSections>

这一段代码。

2.要保证 LogManager.GetLogger(typeof(Respository));在

 var logRepository = LogManager.GetRepository(Assembly.GetEntryAssembly());
XmlConfigurator.Configure(logRepository, new FileInfo("log4net.config"));

这两句之后执行,可以加到startup的构造函数里,参考:

https://stackify.com/making-log4net-net-core-work/

3.记得在Startup类加入[assembly: XmlConfigurator(ConfigFile = "log4net.config", Watch = true)]标记

其中2和3步骤是保证IsErrorEnabled等属性不为false的关键

最新文章

  1. Unhandled Exception:System.DllNotFoundException: Unable to load DLL&quot;**&quot;:找不到指定的模块
  2. AppBox升级进行时 - Attach陷阱(Entity Framework)
  3. 增强:MB1A物料价格检查
  4. CPU与内存的关系
  5. SSO之CAS单点登录详细搭建教程
  6. Spring中WebApplicationContext的研究
  7. Python异常记录
  8. 双机高可用、负载均衡、MySQL(读写分离、主从自动切换)架构设计
  9. Cuckoo hash算法分析
  10. iOS-模糊查询
  11. mysql 查询缓存配置和查看
  12. 轴对称 Navier-Stokes 方程组的点态正则性准则 I
  13. 【转】sqlserver使用sql导出索引
  14. H5 video标签的第二种格式
  15. IP地址和子网划分学习笔记之《IP地址详解》
  16. sql语句查询结果合并union all用法
  17. Android : 跟我学Binder --- (3) C程序示例
  18. override与new的区别
  19. 使用IntelliJ IDEA开发SpringMVC网站(二)框架配置
  20. if语句实例

热门文章

  1. vuejs基础-常见指令(基本结构、v-cloak、v-text、v-html、v-bind、v-model\v-if、v-show)
  2. 基于dvwa环境下级别为low的SQL手工注入教程
  3. Join的7中情况
  4. B+树索引结构解析
  5. 开发中遇到的相关linux问题
  6. HDU 4012 Paint on a Wall(状压+bfs)
  7. Python_pickle
  8. google+ sign in and get the oauth token 转摘:https://gist.github.com/ianbarber/5170508
  9. 【学习总结】Python-3-字符串函数split()的妙用
  10. 一、asp的写法