add new launch.json by going to the Debug view, clicking the 'gear' icon and selecting Apex-Debug
workspaceRoot must point to the root of a mavensmate project
You can set logFile to a hardcoded value, if desired. ${command.AskForLogName} will allow you to select files from debug\logs\
Example launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Apex-Debug",
"type": "apex",
"request": "launch",
"logFile": "${command.AskForLogName}",
"workspaceRoot": "${workspaceRoot}",
"stopOnEntry": true,
"traceLog": false //output log lines as they are processed
}
]
}
Running Debugger
Set log levels in /config/.debug to "ApexCode": "FINEST", "System": "FINE" & "Visualforce": "FINE" (now required to debug VF pages!).
run Mavensmate: Start logging from command pallet
NOTE: There is a known issue with mavensmate where logs are not downloaded when using API v37 and above. Set API version to 36 in Mavenmsate: Global Settings in order to stream logs.
Trigger a log event (Run Anyonmous Apex, load a page, etc). File should show up in debug/logs.
Switch into Debug View
Press the green 'play' button
Select a file (if not hardcoded in launch.json)
Usage Notes
If your classes change from the time you generated the log, things will certainly break
If your log gets too long, Salesforce will truncate it. Try reducing non-required levels (use NONE).
Depending on the execution type, some lines might never be stepped on, dispite the fact they were actually executed. Don't rely on the fact that a breakpoint wasn't hit to indicate that the line was not executed
This will probably never be perfect (although it can be much better than it currently is). Salesforce only gives us so much info to work with.
Supported Opporations
Set Breakpoint
Next
Step into
Step out
Continue
Hit Condition Breakpoints (< 5, >= 10, etc)
Variable Inspection (beta)
[TODO]
Remove depedancy on mavensmate
Conditional Breakpoints
Break on exception
Add/Improve support for all execution types (tests, batch, etc)
Improve stack variable display
Get rid of redudant/bad steps
Contributing
Please Do!
Debugging the Debugger
Fork
Clone
Open in VS code
Open src/apexDebug.ts. Set a break point at start of launchRequest()
Open Debug Window, select Run Server configuration
F5 (starts debugging)
Setup/Open a mavensmate project (See getting started)
Open launch.json and add "debugServer": 4711, above configurations
F5
Your vs-apex-debugger project should stop on breakpoint