Logging in multiple files using NLog

前端 未结 6 2030
长情又很酷
长情又很酷 2020-12-08 00:28

I am using NLog for logging purpose.

My code is as follows:



        
6条回答
  •  抹茶落季
    2020-12-08 01:19

    If you want a separate file to log information from another part of your program, you can add a logger and another target.

    For example, if you have a program that is completing two different tasks and you want to log those tasks separately, you could do the following

    
      
      
    
    
    
      
      
    
    

    Then, in your program, access them with:

    var task1Logger = NLog.LogManager.GetLogger("task1Logger")
    var task2Logger = NLog.LogManager.GetLogger("task2Logger")
    

提交回复
热议问题