Best way to dynamically set an appender file path

后端 未结 4 1155
终归单人心
终归单人心 2020-11-28 06:33

I am trying to find somebody smarter than me to validate some syntax I wrote up. The idea is to configure the filename of my RollingFileAppender to the name of the assembly

4条回答
  •  囚心锁ツ
    2020-11-28 07:16

    Here is way to set or change the logfile of the first appender at runtime:

    var appender = (log4net.Appender.FileAppender)LogManager.GetRepository().GetAppenders()[0];
    appender.File = "C:\whatever.log";
    appender.ActivateOptions();
    

提交回复
热议问题