When working with a scratch org within VSCode, I periodically setup a simple file to test out various Apex commands, etc. I will setup the Apex script and the use VSCode's command palette to run the command "SFDX: Execute Anonymous Apex with Editor Contents" . The execution output is presented in the "Output" panel in VSCode.

That output is the debug log from the execution of my Apex script, but it would appear that the logging level varies depending on various things. In one execution, the output appears to be barely outputting anything. It is consistent with what I would expect to see if I setup a debug logging level with only "ERROR" threshold levels on various outputs.

Then I can go to the Developer console within the org. When I re-run the same script within VSCode and I notice that the output debugging level is higher. Clearly, the activation of Developer console sets up the new logging level and the VSCode output responds to this logging level instead.

So how do we preset the logging level that can be accessible to VSCode? Any suggestions?

1 Answer 1


When you open the Developer Console, it sets up a TraceFlag for your user. This flag exists for up to 24 hours (the expiration date). The only real command we have in VS Code for that is the SFDX: Turn On Apex Debug Log for Replay Debugger command, which will create a TraceFlag suitable for using the Replay Debugger. Alternatively, you could write your own script to create a TraceFlag that has the specified levels, or you could even set up this configuration manually in Setup > Environments > Logs > Debug Logs.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .