• Post Reply Bookmark Topic Watch Topic
  • New Topic

Automate file update  RSS feed

 
Nee Kat
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a logfile which needs to be rolled over every Thursday.
By this I mean that all the information in the file should be deleted on Thursday and logs written on Friday should start in a new file. I don't know how to do this. I am using BufferedWriter to create the file. Here is the code:

BufferedWriter outFile = new BufferedWriter(new FileWriter("/web/boomerang/dev/log/log.IPSearch",true));

Date currentTime = new java.util.Date() ;
String currentDate = currentTime.toString();
outFile.write(currentDate);
outFile.write(" "+ip_address);
..............................
...............................

Is there a way to this because this code is in a servlet and the logfile is modified when the servlet is invoked.

Thanks in advace.
 
Thejesh Nagarathna
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use Log4j for logging.Log4j can be configured outside the code. The conditions you have mentioned is possible using Log4j.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!