0

I have a NLog configutation that writes to a file:

<targets>
  <target name="file"
    xsi:type="File"
    layout="${longdate} | ${level} | ${message}"
    fileName="${basedir}\logs\log.txt"
    archiveFileName="${basedir}\logs\log.{#}.txt"
    archiveEvery="Day"
    archiveNumbering="Rolling"
    maxArchiveFiles="7" />
</targets>

I want the most recent record to appear at the top of the txt file, so I don't have to scroll all the way to the bottom every time I open it since the logs can get very long. This seems like it should be in the configuration, but I'm not seeing it.

Any ideas?

Paul
  • 3,725
  • 12
  • 50
  • 86
  • 2
    I don't think that could be done. Since it would introduce a huge performance penalty, for reading the entire log file into memory, adding the new log entry and rewriting them back. – Xiaoy312 Jan 08 '15 at 21:30
  • 2
    Maybe you could get a text-editor that reads files backwards? – Matthew Jan 08 '15 at 21:33
  • Highly related: http://stackoverflow.com/questions/2041641/log4net-fileappender-writing-new-entries-at-the-beginning-of-file – nemesv Jan 09 '15 at 07:09

0 Answers0