Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

log4net: writing a header to each rollover log segment

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?

like image 752
anthony Avatar asked Jul 30 '10 19:07

anthony


1 Answers

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.

like image 130
Stefan Egli Avatar answered Oct 27 '22 13:10

Stefan Egli