Log4net - FileAppender writes new entries at the beginning of the file

Can I configure FileAppender in log4net to add new entries at the beginning of the log file? He is currently adding records at the end, and reading new records requires scrolling through the entire log. From the very beginning it would be more convenient to read.

+6
log4net fileappender
source share
2 answers

I do not know if this parameter is available in log4net (I would not think so), but even if it is available, I would advise using it.

Adding to a file is a fairly cheap operation. Bytes are simply added to the end of the file. On the other hand, preliminary preparation for the file is quite expensive. The entire file must be read and rewritten with the new data added at the beginning. It also means that it does not scale well, i.e. The operation takes much longer when the file becomes larger.

If you want the entries to be displayed in a different order, you should look for this option in the program that displays the log, or look for a replacement that can display the entries in the reverse order.

+8
source share

Use BareTail to view your log files. It automatically scrolls to the bottom of the viewed files.

+2
source share

All Articles