Configure Log4net to write to multiple files

前端 未结 5 1581
盖世英雄少女心
盖世英雄少女心 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:37

    Vinay is correct. In answer to your comment in his answer, one way you can do it is as follows:

    
        
        
    
    
        
        
    
    

    This is how I have done it in the past. Then something like this for the other log:

    private static readonly ILog otherLog = LogManager.GetLogger("SomeName");
    

    And you can get your normal logger as follows:

    private static readonly ILog log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
    

    Read the loggers and appenders section of the documentation to understand how this works.

提交回复
热议问题