Transaction logging on FileSystem

GM all,

Did someone written transaction logging on File system. If yes, how the log rotation is been taken care ( I mean, per day, it should maintain a file like server.log file ) and if someone has rough code kindly share me which will be helpful… Great thanks to all.

Thanks,
Anil.

Hi,

Write one java service which is like below which takes ‘inputData’ as a string variable:

try{

    IDataCursor pipelineCursor = pipeline.getCursor();
String	inputData = IDataUtil.getString( pipelineCursor, "inputData" );
    DateFormat dateFormat = new SimpleDateFormat("ddMMyyyy");
    String dateString=dateFormat.format(new Date());
    String sFilePath ="logs/transactions/";
    String fileName=sFilePath+"transaction.log."+dateString;  

    File file =new File(fileName);
    if(!file.exists()){ 
 	  file.createNewFile();
    }  
	//true = append file
   	FileWriter fileWritter = new FileWriter(file,true);
    BufferedWriter bufferWritter = new BufferedWriter(fileWritter);
    bufferWritter.write(inputData+"\n");
    bufferWritter.flush();
    bufferWritter.close();
    pipelineCursor.destroy();

}catch(Exception e){
e.printStackTrace();
}

It creates files like transaction.log.04052015 ( for yesterday ), transaction.log.05052015 ( today’s ). So it maintains file per day along with time stamp which is easy to use.

Please let us know if any comments.

Thanks,

Thansk MR, it suits to my need.

Thanks,
Anil.