• 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

Problem in appending current log to existing logfile.

 
Ranch Hand
Posts: 165
Tomcat Server Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, I'm trying to create my own Logger utility. I can create log and add it to my log file but I'm not able to append new logs to my existing file(which already been written) I want each and every call to my log methods to keep on appending to the file and not replacing it completely.

Here are my files.

Constants:-


LogFile:-



MyLogger:-



TestLog:-


Call to infoMsg() in TestLog.java is replacing the existing written log(MyLogger.debugMsg("Hi! This is to verify the logger.")).
Any idea how to deal with it?
 
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The FileWriter class has more than one constructor - maybe using a different one will help.
 
Vinod Vijay
Ranch Hand
Posts: 165
Tomcat Server Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Joanne Neal wrote:The FileWriter class has more than one constructor - maybe using a different one will help.



Any suggestions?
 
Rancher
Posts: 1776
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
May be Jeanne was suggesting on using FileWriter(File file,boolean append) constructor. Can you try that?
 
Joanne Neal
Rancher
Posts: 3742
16
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Actually I was suggesting he read the Javadoc for the FileWriter class so that he wouldn't have to be told the answer.
 
Vinod Vijay
Ranch Hand
Posts: 165
Tomcat Server Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Joanne Neal wrote:Actually I was suggesting he read the Javadoc for the FileWriter class so that he wouldn't have to be told the answer.



Thanks Joanne!
Great, I can see now the messages getting appending. One small issue is there but that is a different thing and my primary concern is resolved now.
Once agian Thanks alot
 
John Jai
Rancher
Posts: 1776
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Joanne Neal wrote:Actually I was suggesting he read the Javadoc for the FileWriter class so that he wouldn't have to be told the answer.


Yes... I just saved the OP from getting a blast from you for not looking into the docs ;) My mistake though
 
Won't you please? Please won't you be my neighbor? - Fred Rogers. Tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic