How to use debug log salesforce for a specific class only?

179    Asked by elonji_3393 in Salesforce , Asked on Mar 3, 2023

 I'm trying to capture the logs for a specific class for a user with a lot of transactions (hundreds in any given minute). For example, the user will have 100 transactions done in a minute that will show up if I turn on debug logs for it; however, I am only interested in seeing the logs for 2 of those transactions that are related to a specific class (e.g., Accounts.cls). I saw the following message on the debug page:

"Class and trigger trace flags override other logging levels, including logging levels set by user trace flags, but they don’t cause logging to occur. "

So how can I target my debug logs to only show the logs for that one specific class and exclude all the others? I found this question to be somewhat relevant but not exactly the same.

Answered by Fiona Dickens

The short answer is, you can't. The class specific debug log salesforce levels only control how verbose the logging for those classes are. When the user executes an action, all the classes within the same context are logged. Theoretically, you can make this easier on yourself by lowering the debug level of all of the classes you don't care about that you expect to show up within the same context but that's still not even close to what you want. You can try to implement a custom logging tool but even then, you're not going to get true logging. You'll only get the information you tell it to give you (which may work for your needs). What I typically do is talk to the user I'm trying to debug. Tell them to stop clicking on things, delete all the debug logs, then tell them to click the one button that executes the action you want logged.

Your Answer


Parent Categories