Configuring log4net with xml file

后端 未结 2 951
挽巷
挽巷 2021-01-07 21:51

I tried to configure log4net for logging everything to the console output. I have a config file named Log4Net.config



        
相关标签:
2条回答
  • 2021-01-07 22:40

    Try this custom configuration through code. Worked for me and tested in multiple apps..

    string logFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "\\Config\\Log4Net.config");
        FileInfo finfo = new FileInfo(logFilePath);
       log4net.Config.XmlConfigurator.ConfigureAndWatch(finfo); 
    

    I understand it's a very late reply. But will be useful for some right.

    0 讨论(0)
  • 2021-01-07 22:42

    When you have log4net config in a separate config file you should not include the configuration and configSections elements. log4net should be the top level element after the xml declartion.

    0 讨论(0)
提交回复
热议问题