• Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem in appending current log to existing logfile.  RSS feed

 
Vinod Vijay
Ranch Hand
Posts: 165
Java Tomcat Server Ubuntu
  • Mark post as helpful
  • send pies
  • 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?
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • 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
Java Tomcat Server Ubuntu
  • Mark post as helpful
  • send pies
  • 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?
 
John Jai
Rancher
Posts: 1776
  • Likes 1
  • Mark post as helpful
  • send pies
  • 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
  • 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
Java Tomcat Server Ubuntu
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!