net core配置log4net需要注意的地方
2024-09-06 02:16:05
和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的关键
最新文章
- Unhandled Exception:System.DllNotFoundException: Unable to load DLL";**";:找不到指定的模块
- AppBox升级进行时 - Attach陷阱(Entity Framework)
- 增强:MB1A物料价格检查
- CPU与内存的关系
- SSO之CAS单点登录详细搭建教程
- Spring中WebApplicationContext的研究
- Python异常记录
- 双机高可用、负载均衡、MySQL(读写分离、主从自动切换)架构设计
- Cuckoo hash算法分析
- iOS-模糊查询
- mysql 查询缓存配置和查看
- 轴对称 Navier-Stokes 方程组的点态正则性准则 I
- 【转】sqlserver使用sql导出索引
- H5 video标签的第二种格式
- IP地址和子网划分学习笔记之《IP地址详解》
- sql语句查询结果合并union all用法
- Android : 跟我学Binder --- (3) C程序示例
- override与new的区别
- 使用IntelliJ IDEA开发SpringMVC网站(二)框架配置
- if语句实例
热门文章
- vuejs基础-常见指令(基本结构、v-cloak、v-text、v-html、v-bind、v-model\v-if、v-show)
- 基于dvwa环境下级别为low的SQL手工注入教程
- Join的7中情况
- B+树索引结构解析
- 开发中遇到的相关linux问题
- HDU 4012 Paint on a Wall(状压+bfs)
- Python_pickle
- google+ sign in and get the oauth token 转摘:https://gist.github.com/ianbarber/5170508
- 【学习总结】Python-3-字符串函数split()的妙用
- 一、asp的写法