场景重现

ASP.NET Core 下集成 log4net 时, 运行时报错如下:

log4net:ERROR ConfigureFromXml called with null 'element' parameter

解决办法

找个一圈后, 发现是 log4net.config 的问题

<!-- log4net.config -->
<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <log4net>
    <!-- more... -->
  <log4net>
<configuration>

去掉 <configuration> 节点, 让 <log4net> 作为最外层节点即可.

<!-- log4net.config -->
<?xml version="1.0" encoding="utf-8"?>
<log4net>
  <!-- more... -->
<log4net>

后续

但是 Visual Studio 小哥会丢个波浪线和警告出来, 令人懊恼, 何解?

log4net:ERROR ConfigureFromXml called with null 'element' parameter

log4net:ERROR ConfigureFromXml called with null 'element' parameter

参考

相关文章:

  • 2022-12-23
  • 2021-08-13
  • 2021-07-31
  • 2021-07-01
  • 2022-01-06
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-06-22
  • 2022-12-23
  • 2021-11-01
  • 2022-12-23
  • 2021-06-06
相关资源
相似解决方案