Have log4net use application config file for configuration data

前端 未结 5 1151
北恋
北恋 2020-12-23 19:34

I would like to store log4net config data in my application.config file. Based on my understanding of the documentation, I did the following:

  1. Add a referenc

5条回答
  •  自闭症患者
    2020-12-23 20:07

    Add a line to your app.config in the configSections element

    
     

    Then later add the log4Net section, but delegate to the actual log4Net config file elsewhere...

    
    

    In your application code, when you create the log, write

    private static ILog GetLog(string logName)
    {
        ILog log = LogManager.GetLogger(logName);
        return log;
    }
    

提交回复
热议问题