2

I've just started playing around with log4net, but I cannot seem to find to get the FileAppender to prepend data to the file, instead of appending it. So, for example what I'd like:

 [5:45] WARN newest log entry
 [5:40] ERROR older log entry
 [3:20] FATAL oldest log entry

Instead of the default appending behavior which results in the reverse

 [3:20] FATAL oldest log entry
 [5:40] ERROR older log entry
 [5:45] WARN newest log entry

I've looked over the documentation for each Appender on the log4net site and found nothing. I was able to find plenty of answers for simply prepending data to a file programmatically, but nothing for log4net. Is it not possible?

Alternatively, I considered simply just scrolling the file to the bottom when the user tells the application to launch the log file, but how to do that varies based on which editor gets launched, so I'm out of ideas.

sab669
  • 3,984
  • 8
  • 38
  • 75
  • 1
    I would consider a different approach. Prepending is a *much* more time-consuming process than appending. One of log4net's strengths, and IMHO one of its essential qualities is how fast it executes. Consider a database appender instead of a file appender. That way, you can do whatever SQL magic you need to present the data accordingly. – Bob Kaufman Nov 11 '13 at 15:28
  • 1
    devio suggests [here](http://stackoverflow.com/a/2041803/724591) that you could use [BareTail](http://www.baremetalsoft.com/baretail/) to monitor these files, as it supports scrolling to the bottom automatically. – matth Nov 11 '13 at 15:30
  • Thanks for the tip, @BobKaufman. I was unaware prepending is a more taxing process. Unfortunately, anything but a local file is out of the question for this particular project. – sab669 Nov 11 '13 at 15:37

0 Answers0