Extract from the TraceFlag docs:
A reference to a user. This field is used with the TracedEntityID field.
ScopeId=user the actions of the user/entity specified by
TracedEntityID (user, Apex class or Apex trigger) are traced to the system log at the described level.
ScopeId=emptyid the user’s actions are traced to the organization’s debug log at the described level.
A reference to the following:
- Apex class
- Apex trigger
I've often used both the
ScopeId and the
TracedEntityId set to the userId of the current active user.
If you go to the Log Filters tab Apex class or trigger and override the Log Filters a Trace flag will be created.
Note that when it is created the Expiration Date was the time that it was created.
When the trigger fires, this will manifest itself as PUSH_TRACE_FLAGS and then finish at POP_TRACE_FLAGS.
It won't however cause the log to be generated, regardless of the expiration date.
This corresponds to the "Check Log Levels" in the developer console, that will show the trigger specific flag under "Class and Trigger Trace Overrides" without an Expiration column.
You will need an active TraceFlag (expiration in the future), with the TracedEntityId of the user in question.
I don't know of a way to trace all the users in an org without creating a TraceFlag for each of them. Support might have some black tab functionality for this, but it isn't directly accessible to us.
Appears the current documentation doesn't align with how logging actually works, at least with respect to creating system logs for specific Apex classes and triggers.
Purely speculation on my part, but I don't think the logging system would work for the trigger or apex class in isolation. When an execution context starts a check is made if logging will be required for the duration based on the user. This same check isn't made for every trigger and class that is called. It wouldn't be practical, as the execution could move in and out of numerous classes and triggers for one execution.