log4net configuration - failed to find section

后端 未结 2 1835
生来不讨喜
生来不讨喜 2020-12-10 11:36

This is my error message:

log4net:ERROR XmlConfigurator: Failed to find configuration section \'log4net\' in the application\'s .config file. Check your .con         


        
2条回答
  •  不知归路
    2020-12-10 12:17

    Nothing seems wrong with defining the section under .

    Try adding [assembly: log4net.Config.XmlConfigurator(Watch = true)] in your AssemblyInfo.cs in the properties folder of your project. This should do the trick in case your configuration is correct under the tag.

    EDIT :

    XmlElement log4NetSection = (XmlElement)ConfigurationManager.GetSection("log4net");
                log4net.Config.XmlConfigurator.Configure(log4NetSection);
    

提交回复
热议问题