[SalesForce] How to see anonymous code debug logs in visual studio code

I installed the Salesforce CLI and the Salesforce Salesforce Extension Pack on Visual Studio Code because it's easier to write code than the Developer Console but I got a problem. I want to get the debug log files when I run some code from Anonymous Block, but I can only see the output in the 'OUTPUT' tab on VSCode, there's no file in the project folder. How can I fix this?

Example (anonymous code from VSCode):

Account a = new Account();
a.name = 'Test Account';
insert a;
System.debug('Account inserted');

How can see the log file of the execution of this code block?

Solution:
I solved the issue adding an User Trace Flag from Setup -> Debug Logs.

Best Answer

I would make sure you have an active User Trace Flag. I have noticed that in vscode sometimes you need to have your user trace flag set even when running anonymous apex.

Related Topic