| 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>
|
 |
 |
|
|
subject: Automate file update
|
|
|