[SalesForce] Start ApexLog capture via the API

When the developer console is opened Salesforce will start capturing ApexLog records for the current user. After a period of time this stops occurring and the user needs to click the resume menu method so the logs start updating again.

Alternatively, you can start a similar capture process from

Setup > Administration Setup > Monitoring > Debug Logs > Monitored Users – New

If neither of these options are active no ApexLog entry gets created.

How can I start the capturing of ApexLog records using just the API?

I'd imagine the tooling API would be the place to start, but the Metadata or partner APIs would also be fine.

Best Answer

Found it it in the Tooling API -

TraceFlag
Represents a trace flag that triggers an Apex debug log at the specified logging level.


• To set up a log for a specific user, set ScopeId to null and TracedEntityId to the ID of the user. This option can only be configured for a user, not an Apex class or Apex trigger.
• To configure logging levels for system logs (visible only to you), set ScopeId to user and TracedEntityId to the ID of the logged-in user.
• To set up a system log (visible only to you) for a specific Apex class or trigger, set ScopeId to user and TracedEntityId to the ID of the Apex class or trigger.

There is a good explanation in the answer to Debugging logs in Developer Console is not working

Related Topic