• Post Reply Bookmark Topic Watch Topic
  • New Topic

Append to beginning of file (log4j)  RSS feed

 
Yuri Morais
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Folks,
I'm using log4j to generate logs in my application.
I have overriden HTMLLayout class to change the style of the generated page.
I'm using DailyRollingFileAppender

Would you know how can I write all the log entries in the beginning of the file, instead of write to the end.

Best,
Yuri
 
Paul Clapham
Sheriff
Posts: 22185
38
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Whether it's log4j doing it or anything else in any language whatever, appending text to the beginning of a file is an ugly process that goes like this:

1. Write the new text to a new file.
2. Copy all the old text from the old file, appending it to the new file.
3. Delete the old file.
4. Rename the new file.

Obviously that isn't something you would want a logging package doing on a regular basis. So I would suggest you review your requirements and find a different way to implement whatever requirement prompted that idea.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!