Why is the date appended twice on filenames when using Log4Net?

前端 未结 6 573
北荒
北荒 2021-02-01 18:52

I was trying to add the date to my log file name and I was able to make it work by following the few suggestions I\'ve found in stackoverflow. Everything works fine but for some

6条回答
  •  日久生厌
    2021-02-01 19:16

    I run into the same problem. For me, it was a combination of using RollingFileAppender for my test logs, and running my NUnit tests with ReSharper.

    It turns out that ReSharper uses two processes to run the tests:

    2 TaskRunners

    which creates a race condition on the log file.

    Now, if we change the log file name to include the process id:

    
      
      
      
      
      
      
      
      
        
      
    
    

    the problem is solved. Each file gets its own, unique name:

    MyLog.pid.5440_2010-10-13.log
    MyLog.pid.1496_2010-10-13.log

    Note the use of PatternString for 'type'.

    Hope that helps.

提交回复
热议问题