• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Append to beginning of file (log4j)

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic