Log4Net separate config file not working

前端 未结 2 1924
逝去的感伤
逝去的感伤 2021-02-15 15:27

I\'m having a strange problem. I have multiple projects in a solution. One of them is a WebAPI and it logs just fine. Another is an MVC admin site, this one won\'t log. Here

2条回答
  •  谎友^
    谎友^ (楼主)
    2021-02-15 15:35

    I struggled for this solution for many days. I could finally found below solution worked for me>

    [assembly: log4net.Config.XmlConfigurator(ConfigFile = "log4net.config", Watch = true)] plus the configuration suggested by @BCarlson

    XmlConfigurator.ConfigureAndWatch(new System.IO.FileInfo(AppDomain.CurrentDomain.BaseDirectory + "log4net.config"));
    

    To summaries everything, I have created a sample c# console project for log4net configuration with external log4net.config file. https://github.com/riddhik84/Log4net-Tutorial

提交回复
热议问题