log4net - FileAppender writing new entries at the beginning of file

后端 未结 2 1023
小蘑菇
小蘑菇 2021-01-18 09:29

Is it possible to configure FileAppender in log4net to add new entries at the beginning of log file? Currently it is adding entries at the end and reading newest entries req

相关标签:
2条回答
  • 2021-01-18 10:02

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

    0 讨论(0)
  • 2021-01-18 10:04

    I don't know if that option is available in log4net (I wouldn't think so), but even if it's available I would advise against using it.

    Appending to a file is a quite cheap operation. The bytes are just added to the end of the file. Prepending to a file on the other hand is rather expensive. The entire file has to be read and rewritten with the new data added at the beginning. This also means that it scales badly, i.e. the operation takes a lot longer when the file gets bigger.

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

    0 讨论(0)
提交回复
热议问题