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.

About Bhabani 86 Articles
Bhabani has 10 plus years of experience in Data warehousing and Analytics projects that has span across multiple domains like Travel, Banking and Financial, Betting and Gaming Industries. Solution areas he focuses on designing the data warehouse and integrating it with cloud platforms like AWS or GCP. He is also a Elite level contributor at OTN forum more than 9 years. He loves to do experiment and POC on different integration tools and services. Some of his favorite skills are Redshift, Big Query, Python, Apache Airflow, Kafka, HDFS, Map Reduce ,HIVE, Habse, Sqoop, Drill, Impala.

Be the first to comment

Leave a Reply

Your email address will not be published.


*