5

I have a RollingFileAppender that rolls over the log file when it reaches a specified file size. This works great.

Is there a way to have log4net insert a header at the top of each newly created log file? Alternatively, is there a way to be notified by log4net when a roll over occurs so that I can write this header myself?

hometoast
  • 11,522
  • 5
  • 41
  • 58
anthony
  • 40,424
  • 5
  • 55
  • 128

2 Answers2

7

This seems to work:

<layout type="log4net.Layout.PatternLayout">
     <header value="[Header]&#13;&#10;" />
     <conversionPattern value=" ... " />
</layout>

Though it will also write the header if you re-start the application.

Stefan Egli
  • 17,398
  • 3
  • 54
  • 75
3

I think you may have to extend an appender or write your own appender for this.

Skyler
  • 341
  • 2
  • 10