Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how format log file name

Status
Not open for further replies.

fuadhamidov

Programmer
Sep 22, 2003
98
TR
hi

i want to change my log file name:
the previous one like

error_outletim.log.2004-03-04

i want to name my log files like

error_outletim.2004-03-04.log

 
Got the Answer for your ? .
Since i am facing the same issue. Please share your answer

P
 
Hi guys,

I hv the same problem but am working on a workaround. Create a class , dump in the code to rename the file and run this class as a batch/ chrome soon after the log is created.. here´s what I hv done:

String path = "F:\\bea\\user_projects\\applications\\contents\\logs";
String newpath = "F:\\TMN\\junk\\";
String cmp = "WCM_export";

File file = new File(path);
File str[] = file.listFiles();

for(int i=0; i<str.length; i++){

if(str.isFile()){
// System.out.println(str.getName() + "--------" + str.getName().length());
String s = str.getName().substring(0,10);

if(s.equalsIgnoreCase(cmp)){
//File Newfile = new File(str.getAbsoluteFile()+".csv");
File Newfile = new File(newpath+str.getName()+".csv");
str.getAbsoluteFile().renameTo(Newfile);
}
}
}

hope this is usefull..

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top