1

I'm in SFDX/VSCode, using the sfdx force:apex:log:tail command. That makes it easy to pull up the latest log, but when I try to launch the debugger, it says I need Apex at FINEST and VisualForce at FINER. Where do I set that? Does it go in the cli command? Or is this in a json config file?

Or, do I go into my scratch org and set it there and then reference the name of that config?

UPDATE: I got it working by going into the dev console of the scratch org and creating a new debug level I called dx, then calling it in the cli. That seems like a roundabout way of doing it, so I think I'm probably missing something easier.

3

You need to set the debug level on the DEVELOPER_LOG trace flag for your user. It is written in the documentation:

-d | --debuglevel DEBUGLEVEL

Optional

Debug level to set on the DEVELOPER_LOG trace flag for your user.

Type: string

There's an example right below the command documentation:

$ sfdx force:apex:log:tail --debuglevel MyDebugLevel

So you set Apex to FINEST and Visualforce to FINE in MyDebugLevel in your org, and tell the command to use it.

The --debuglevel parameter assigns a debug level to the active DEVELOPER_LOG trace flag.

As Thomas pointed out on the comments, it is possible to use the CLI to script this DebugLevel creation, using the force:data:record:create with the -t | --usetoolingapi parameter.

sfdx force:data:record:create -s DebugLevel -t -v "DeveloperName=From_CLI MasterLabel=From_CLI ApexCode=FINEST ApexProfiling=FINER Callout=DEBUG Database=Debug System=DEBUG Validation=FINE Visualforce=FINEST Workflow=WARN"
| improve this answer | |
  • I saw that in the docs, but there are no examples of the command. Is it -d='Apex=FINEST, VisualForce=FINER'? – PatMcClellan__c Jul 1 '19 at 18:10
  • You should create the debug level and pass its name, if I understood correctly. I edited the post to add the example. – Renato Oliveira Jul 1 '19 at 18:18
  • 1
    Got it, thanks. Sorry to seem so slow... just seems weird to go from the elegance of the cli and json config files to the clunkiness of the dev console. I thought I was missing something easy. – PatMcClellan__c Jul 1 '19 at 18:30
  • 1
    You can use sfdx force:data:record:create with the -t | --usetoolingapi flag to create a DebugLevel (see Tooling API docs for required fields and values). eg: sfdx force:data:record:create -s DebugLevel -t -v "DeveloperName=From_CLI MasterLabel=From_CLI ApexCode=FINEST ApexProfiling=FINER Callout=DEBUG Database=Debug System=DEBUG Validation=FINE Visualforce=FINEST Workflow=WARN" You'd want to script that - no option to pass a file. – Thomas Taylor Jul 1 '19 at 19:29
  • 1
    @ThomasTaylor thanks! That's pretty wordy, but easy enough to create a BASH alias – PatMcClellan__c Jul 2 '19 at 16:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.