Skip to content

Instantly share code, notes, and snippets.

@ShubhamS32
Created March 6, 2019 09:59
Show Gist options
  • Select an option

  • Save ShubhamS32/7e0b2bf16ec26313feb38feeebc0f282 to your computer and use it in GitHub Desktop.

Select an option

Save ShubhamS32/7e0b2bf16ec26313feb38feeebc0f282 to your computer and use it in GitHub Desktop.
For Logging Purpose
//log.append(reqTime +" |Exception appErrorCode"+appErrorCode + "| httpErrorCode |"+httpErrorCode);
// logit("PayTM_Exp_Log",true,reqTime,log.toString());
public static void logit(String filename,boolean newline,String ...X){
try{
//String path="C:\\logs\\atom\\";
String path ="C:\\logs\\paytm";
StringBuffer sb = new StringBuffer();
String today = new SimpleDateFormat("MMM-dd-yyyy").format(new java.util.Date());
BufferedWriter outlog = new BufferedWriter(new FileWriter(path+"\\"+filename+"-"+today+".log", true));
for(String str:X){
sb.append(str).append(",");
}
outlog.write(sb.toString());
outlog.flush();
if(newline){
outlog.newLine();
}
outlog.close();
}catch(Exception e){
e.printStackTrace();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment