Configure Log4net to write to multiple files

前端 未结 5 1585
盖世英雄少女心
盖世英雄少女心 2020-11-27 10:07

I\'d like to write log to 2 different log files from the same process.

is that possible thing to do using log4net?

I\'ll need to write separate messages to

5条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-27 10:18

    These answers were helpful, but I wanted to share my answer with both the app.config part and the c# code part, so there is less guessing for the next person.

    
      
        
        
        
        
        
        
      
      
        
        
      
      
        
        
      
      
        
        
      
    
    

    Then in code:

    ILog Log = LogManager.GetLogger("SomeName");
    ILog SummaryLog = LogManager.GetLogger("Summary");
    Log.DebugFormat("Processing");
    SummaryLog.DebugFormat("Processing2"));
    

    Here c:/Console.txt will contain "Processing" ... and \SummaryFile.log will contain "Processing2"

提交回复
热议问题