
Debug Logs in SFDC
Debug Log A debug log can record database operations, system processes, and errors that occur when executing a transaction or running unit tests. Debug logs can contain information about:
- Apex Code
- Apex Profiling
- Callout
- Database
- System
- Validation
- Visualforce
- Workflow
Step 1. From Setup, enter Debug logs.
Step 2. To set the Debug Logs, click on new,
Step 3. Select User, Start Date and Expiration Date. Expiration date must be a future date and also select the debug level and than click on save button.
Step 4. How to view, download and delete debug logs.
Step 5. To view Debug logs, Let’s take an example of trigger to see back-end process.
trigger AccountTrigger on Account (before insert , before update){
for(Account a:trigger.new)
{
if(a.Name=='Shahwaz')
{
a.Description='New Description';
}
}
}
Flow of Execution
/* start execution */
trigger TriggerOne on Account (before insert){
ClassA.MethodA();
ClassB.MethodB();
}
public class ClassA{
public static void MethodA(){
ClassC.MethodC();
}
}
public class ClassB{
public static void MethodB(){
// code
}
ClassC.MethodC();
}
public class ClassC{
public static void MethodC(){
// Some code
}
}
/* End execution */
Description of Log Category
Log category | Description |
Database Workflow Validation Callout Apex Code Apex Profile Visualforce System | Information of Data manipulation language (DML). Information of workflow rules, process and flows. Information about validation rule. Includes request and response. Information of Apex Code. Profile information such as no of email sent. Information of visualforce event. Information of system method such as system.debug method. |
Step1. You can use the Developer console and execute anonymous functionality for debugging. Example: Write this code in anonymous window and execute: list<Account> listacc =[select id, name from account limit 10]; System.debug(‘AccountList’ + listacc);
Step 2. Click on log tab
Step 3. Open log
Debug Logs Limitations 1.Each Debug log size is of 5 MB or smaller. If a Debug log is greater than 5 MB, then it’s size is reduced by removing older log lines, such as System.debug statements.
2.System debug log is retained for 24 hours. Monitoring debug logs are retained for seven days.
3. If Debug logs size is more than 250 MB in a 15-Minute Window your trace flags are disable to prevent user to add and edit trace flags. You can generate more logs once you reach a limit and before you edit trace flags, delete some debug logs. Each trace flags includes Start Date, Expiration Date and debug level.