Cliq Process audit count from log file using Java

Cliq Process audit count from log file using Java:

If you are aware of the Cliq Process available in salesforce then you must be aware of the log file generated by it. This log file contains information about the records loaded successfully and about the failed ones. The only problem with this process is, you will not have any notification mail based on the error/success count.

You have to write a small piece of code to extract the count and embed it to the base package. Based on the count , you can call your java mail to send the notification..

This seems to be very easy but just thought to share with you.  

 

import java.io.File;
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

class FindLog {

public static void main(String args[]){
String fileName="C:\\Program Files\\salesforce.com\\Apex Data Loader 23.0\\cliq_process\\IncidentReasonInsert\\log\\sdl.log";
String phraseread="The operation has fully completed. There were ";
String phraseread1=" successful extractions and ";

File f = new File(fileName);

if(f.exists()){
try{
Scanner fileScanner = new Scanner(new File(fileName));
Pattern pattern = Pattern.compile(phraseread);//,Pattern.CASE_INSENSITIVE);
Matcher matcher = null;
while(fileScanner.hasNextLine()){
String line=null,read=null;
int val=0;
line= fileScanner.nextLine();
matcher = pattern.matcher(line);
if(matcher.find()){
val=line.indexOf(phraseread);
read=line.substring(val+47);
int scount= Integer.parseInt(read.substring(0, read.indexOf(" ")));
System.out.println(scount);
}
}
} catch(Exception e){}
try{
Scanner fileScanner = new Scanner(new File(fileName));
Pattern pattern = Pattern.compile(phraseread1);//,Pattern.CASE_INSENSITIVE);
Matcher matcher = null;
while(fileScanner.hasNextLine()){
String line=null,read=null;
int val=0;
line= fileScanner.nextLine();
matcher = pattern.matcher(line);
if(matcher.find()){
val=line.indexOf(phraseread);
line=line.substring(val,line.lastIndexOf(" "));
read= line.substring(line.lastIndexOf(" ")+1);
int ecount= Integer.parseInt(read);
System.out.println(ecount);
}
}
} catch(Exception e){}
}
}
}

 

Let me know if you face any issues.

0

About the author

Bhabani(http://dwteam.in) - Currently Bhabani is working as Sr Development Engineer at Harman International. He has good expertise on Oracle, Oracle Data Integrator, Pervasive Data Integrator, MSBI, Talend and Java. He is also contributing in ODI-OTN forum for last 5 years. He is from India. If you want to reach him then please visit contact us page. If you have any doubts or concerns on the above article, please put your question here. Dw Team will try to respond it as soon as possible. Also dont forget to provide your comments / suggestions / feedback for further improvement. Thanks for your time.

Similar Posts

Find Process ID in Windows using Java
Rename All Files in a Directory

Leave a reply

required*

Are you a human? *