Wednesday, September 30, 2015

The Trace Flag and Debug Level in Salesforce Force.com

This feature wasn't in  before until I noticed it in Sep 2015, round about the Dreamforce. And I somewhat figured it out myself navigating here and there in the Debug Log screen.

So when you go to Setup - Monitoring - Debug Log, we only used to see the "DEBUG LOG" section.

Now we see two sections, the "USER TRACE FLAGS" section and we have the legacy "DEBUG LOG" section right below it.

To debug your Apex code, click on the 'NEW' button in the USER TRACE FLAGS section.

Now this new feature is powerful. The Trace Entity dropdown will allow you to select User, Apex Class, Apex Trigger, which means you can debug your code in a more granular fashion by targeting what you want user/component to debug.

Now say you are debugging a functionality in your Salesforce org for a specific user, select "USER" in the dropdown and specify that user's name.

The start date & end date cannot be more than 24 hours apart. Salesforce still wants to track on how much we can debug at a time. In short, there is still a limit on how much we can debug.

The Debug Level is something new you will see here. In the beginning, you wont have any Debug Level of your own. You will have to create your own customized Debug Levels here. So for that, click the Search button on the Debug Level field and this will open a popup for you.

Because you do not have any debug level to start with, you really cant search and go. So click on 'New'.

Here you can define your own name for your choice of Debug Level.

Next, you can select your debug choice from each of the following dropdowns available: Database, Workflow, Validation, Callout, Apex Code, Apex Profiling, Visualforce, System.

Thats it, Save your Debug Level. Go back to the Trace Flags screen and save your settings.

Once done, you can start debugging the code for the user you specified.

Go get better at freaking debugging.


No comments:

Post a Comment