This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Java in General and the fly likes Automate file update Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Automate file update" Watch "Automate file update" New topic
Author

Automate file update

Nee Kat
Ranch Hand

Joined: Jan 27, 2004
Posts: 37
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

Joined: Feb 10, 2005
Posts: 3
You can use Log4j for logging.Log4j can be configured outside the code. The conditions you have mentioned is possible using Log4j.


My tutorials:<br /> <a href="http://www.techmag.biz" target="_blank" rel="nofollow">www.techmag.biz</a>
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Automate file update
 
Similar Threads
How do I close a file
New Problem
Replacing a perticular text in property file keeping other content intact
JfileChooser selecting existing file.......?
setting Timezone for web application