4

Anyone know of a working debugger extension for VS Code that works for non-DX projects? Or maybe how to setup the official SF debugger extension for a non-DX project (their wiki mentions it can be used for both sandboxes and scratch orgs)?

Salesforce Debugger Wiki:

Apex Debugger allows customers to debug their Apex code on sandbox instances (including in scratch orgs), in real time

I've read that they're dropping support for the Eclipse plugin and the Eclipses based IDE 2 so I've completely migrated to VS Code. I've used the official SF Debugger Extension on a DX project and it works great. But I also have times when I need to track down a bug and setting up a DX project would take longer than to just running through the affected classes.

Currently I use the ForceCode extension (which is also no longer being developed) to pull down and deploy code fixes. I've read somewhere that the MavensMate extension (also no longer being developed) supports non-live debugging by reading through a debug log, but I can't get MavensMate to work from within our proxy.

7
  • Please see if @andrew-fawcett blog post can be helpful Streaming Debug Logs to your console
    – o-lexi
    May 21, 2018 at 22:17
  • that was interesting, I didn't know we can do that. the color, grep, and pipe would definitely make reading logs easier But, this still isn't an alternative to live debugging. For example, I won't be able to put in break points, examine variable values, step through code, etc..
    – John
    May 24, 2018 at 18:26
  • Due to the SF architecture, it's impossible to have a real-time debugger. The closest thing is Apex Retrospective Debugger available in The Welkin Suite
    – o-lexi
    May 25, 2018 at 21:06
  • 2
    @o-lexi they do have a debugger, and it worked well in Eclipse for Non-DX as well as in VS Code if using DX. I've used both and they were good. But what I'm looking for is to setup for VS Code for Non-DX projects.
    – John
    Jun 7, 2018 at 15:25
  • FYI for future readers.. Apex Debugging is now working with non-DX projects in VSCode. I just tried.
    – javanoob
    Jan 16, 2019 at 18:00

2 Answers 2

1

Regardless of which extensions you are using, as long as you have the cli installed, and you just want to emit your debug statements, this will work in VS Code, go to the terminal window and enter this command:

sfdx force:apex:log:tail --color | grep USER_DEBUG 

Then run your tests. The debug messages will show up in the Terminal window. This will not give you breakpoints etc. of course.

Also be aware, you can work on non-DX orgs but still have your code in DX format, which will allow you to use the native debugging within VSCode (assuming you have the Salesforce Extensions Pack, which you should). The CLI has a converter, and so in your source control / local workspace, the code can be in the DX structure, but when you save/publish to the org, the cli automatically converts it back to the MDAPI format.

To convert to DX format use: sfdx force:mdapi:convert

-2

Use Apex Replay Debugger:

Why: Apex Debugger, our interactive debugger, debugs only sandboxes and scratch orgs. But you can use Apex Replay Debugger in any org that you have source code and a debug log for, including your production org. Apex Replay Debugger is not only free, it's open source!

VSCode has plugins and supports node modules which provide the following features:

  • Code Retrieval and Deployment1
  • VisualForce Linting2
  • Apex Linting3
  • Static Analysis4
  • Command line Testing5

References

1
  • 2
    A linter is not the same thing as a debugger - can you clarify how these resources support OP's objective?
    – David Reed
    Dec 12, 2018 at 17:29

You must log in to answer this question.

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