Log4Net, RollingFile named by Date and the staticLogFileName setting

· December 13, 2011

We have been chasing some strange logging bugs for a while in my current project. We are using log4net to do our logging and it works fine … until a couple of weeks ago. Some logging didn’t occur, in another case we didn’t get new files…

The fix is, very simple, but quite surprising and I thought I’ll share something on what we did to fix it.

We are using a RollingFileAppender and common strategy for how to handle the log files; we’re creating a new file for each new date. In order to achieve this we have set the following configuration:

1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: OK – nothing strange here really. And actually it worked fine for a long time. But all of a sudden we have ran into the problems I described above. The solution is simply to add the “staticLogFileName” element to the configuration above, setting the value to false;
1: And with that it started to work again. I found some questions around this on StackOverflow that was related but not exactly this. So if you name your RollingFiles logs with log4net with Dates – be sure to include the staticLogFileName = false setting.

Twitter, Facebook