How to view complete system.debug logs in salesforce? - Salesforce Globe For You
Problem: When we use system.debug in Apex methods for debugging and when we run that method,the debug log string gets truncated and displays half of the result sometimes.
Solution:you can view complete debug value using 'Open Raw Log' option in the logs tab of Developer console.
Example:
public class ViewCompleteJSONController {
public static void viewJSON() {
List<LeadWrap> lstLeadWrap = new List<LeadWrap>();
For(Lead objLead:[Select id,name,company,status from Lead]) {
LeadWrap objWrap = new LeadWrap();
objWrap.name = objLead.name;
objWrap.company = objLead.company;
objWrap.status = objLead.status;
lstLeadWrap.add(objWrap);
}
system.debug('Lead JSON:'+JSON.serialize(lstLeadWrap));
}
public class LeadWrap {
public String name {get;set;}
public String company{get;set;}
public String status {get;set;}
}
}
When we run the method in developer console using Debug --> Open Execute Anonymous Window
ViewCompleteJSONController.viewJSON();
The debug log gets display but string may appear as truncated.
To view complete string ,go to that logand right click,you will get the option to 'Open Raw Log' as shown in the image below.
Now,on click it,the debug log appears completely.
Enjoy
No comments:
Post a Comment