TraceFlag

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

Version 

Introduced in API version 25.0.

Supported SOAP API Calls 

create(), delete(), describeSObjects(), query(), retrieve(), update(), upsert()

Supported REST API Methods 

DELETE, GET, HEAD, PATCH, POST, Query

Fields 

ApexCode 

  • Type: picklist

  • Required: No

  • Properties: Create, Filter, Group, Nillable, Restricted picklist, Sort, Update

  • Description: The log category level for Apex code. Includes information about Apex code. Can also include log messages generated by data manipulation language (DML) statements, inline SOQL or SOSL queries, the start and completion of triggers, the start and completion of test methods, and so on. The following are valid values.

This field is required.

  • Possible values:

    • NONE — None

    • INTERNAL — Internal

    • FINEST — Finest

    • FINER — Finer

    • FINE — Fine

    • DEBUG — Debug

    • INFO — Info

    • WARN — Warn

    • ERROR — Error

ApexProfiling 

  • Type: picklist

  • Required: No

  • Properties: Create, Filter, Group, Nillable, Restricted picklist, Sort, Update

  • Description: The log category level for profiling information. Includes cumulative profiling information, such as the limits for your namespace, the number of emails sent, and so on. The following are valid values.

This field is required.

  • Possible values:

    • NONE — None

    • INTERNAL — Internal

    • FINEST — Finest

    • FINER — Finer

    • FINE — Fine

    • DEBUG — Debug

    • INFO — Info

    • WARN — Warn

    • ERROR — Error

Callout 

  • Type: picklist

  • Required: No

  • Properties: Create, Filter, Group, Nillable, Restricted picklist, Sort, Update

  • Description: The log category level for callouts. Includes the request-response XML that the server is sending and receiving from an external Web service. The request-response XML is useful when debugging issues related to SOAP API calls. The following are valid values.

This field is required.

  • Possible values:

    • NONE — None

    • INTERNAL — Internal

    • FINEST — Finest

    • FINER — Finer

    • FINE — Fine

    • DEBUG — Debug

    • INFO — Info

    • WARN — Warn

    • ERROR — Error

DataAccess 

  • Type: picklist

  • Required: No

  • Properties: Create, Filter, Group, Nillable, Restricted picklist, Sort, Update

  • Introduced: API version 63.0

  • Possible values:

    • NONE — None

    • INTERNAL — Internal

    • FINEST — Finest

    • FINER — Finer

    • FINE — Fine

    • DEBUG — Debug

    • INFO — Info

    • WARN — Warn

    • ERROR — Error

Database 

  • Type: picklist

  • Required: No

  • Properties: Create, Filter, Group, Nillable, Restricted picklist, Sort, Update

  • Description: The log category for database activity. Includes information about database activity, including every DML statement or inline SOQL or SOSL query. The following are valid values.

This field is required.

  • Possible values:

    • NONE — None

    • INTERNAL — Internal

    • FINEST — Finest

    • FINER — Finer

    • FINE — Fine

    • DEBUG — Debug

    • INFO — Info

    • WARN — Warn

    • ERROR — Error

DebugLevelId 

  • Type: reference

  • Required: No

  • Properties: Create, Filter, Group, Nillable, Sort, Update

  • Introduced: API version 35.0

  • Description: The ID of the debug level assigned to this trace flag. A debug level, which is a set of log category levels, can be assigned to multiple trace flags.

  • Relationship name: DebugLevel

  • Relationship type: relationship

  • Refers to: DebugLevel

ExpirationDate 

  • Type: datetime

  • Required: No

  • Properties: Create, Filter, Nillable, Sort, Update

  • Description: The date and time that the trace flag expires. ExpirationDate must be less than 24 hours after StartDate. Only one trace flag per traced entity can be active at a time. If StartDate is null, the current time is used, and the ExpirationDate must be less than 24 hours from the current time.

This field is required.

LogType 

  • Type: picklist

  • Required: No

  • Properties: Create, Filter, Group, Nillable, Restricted picklist, Sort

  • Introduced: API version 35.0

  • Description: The type of log to generate. The following are valid values.

  • CLASS_TRACING

  • DEVELOPER_LOG

  • PROFILING (reserved for future use)

  • USER_DEBUG

When you open the Developer Console, it sets a DEVELOPER_LOG trace flag to log your activities. USER_DEBUG trace flags cause logging of an individual user’s activities. CLASS_TRACING trace flags override logging levels for Apex classes and triggers, but don’t generate logs.

This field is required.

  • Possible values:

    • USER_DEBUG — USER_DEBUG

    • DEVELOPER_LOG — DEVELOPER_LOG

    • CLASS_TRACING — CLASS_TRACING

    • PROFILING — PROFILING

Nba 

  • Type: picklist

  • Required: No

  • Properties: Create, Filter, Group, Nillable, Restricted picklist, Sort, Update

  • Introduced: API version 43.0

  • Possible values:

    • NONE — None

    • INTERNAL — Internal

    • FINEST — Finest

    • FINER — Finer

    • FINE — Fine

    • DEBUG — Debug

    • INFO — Info

    • WARN — Warn

    • ERROR — Error

StartDate 

  • Type: datetime

  • Required: No

  • Properties: Create, Filter, Nillable, Sort, Update

  • Introduced: API version 35.0

  • Description: The date and time when the trace flag takes effect. ExpirationDate must be less than 24 hours after StartDate. Only one trace flag per traced entity can be active at a time. If StartDate is null, ExpirationDate must be less than 24 hours from the current time.

System 

  • Type: picklist

  • Required: No

  • Properties: Create, Filter, Group, Nillable, Restricted picklist, Sort, Update

  • Description: The log category level for calls to all system methods, such as the System.debug method. The following are valid values.

This field is required.

  • Possible values:

    • NONE — None

    • INTERNAL — Internal

    • FINEST — Finest

    • FINER — Finer

    • FINE — Fine

    • DEBUG — Debug

    • INFO — Info

    • WARN — Warn

    • ERROR — Error

TracedEntityId 

  • Type: reference

  • Required: No

  • Properties: Create, Filter, Group, Sort

  • Description: A reference to the following:

  • Apex class

  • Apex trigger

  • User

This field is used with the LogType field. This field is required.

Validation 

  • Type: picklist

  • Required: No

  • Properties: Create, Filter, Group, Nillable, Restricted picklist, Sort, Update

  • Description: The log category level for validation rules. Includes information about validation rules, such as the name of the rule, or whether the rule evaluated true or false. The following are valid values.

This field is required.

  • Possible values:

    • NONE — None

    • INTERNAL — Internal

    • FINEST — Finest

    • FINER — Finer

    • FINE — Fine

    • DEBUG — Debug

    • INFO — Info

    • WARN — Warn

    • ERROR — Error

Visualforce 

  • Type: picklist

  • Required: No

  • Properties: Create, Filter, Group, Nillable, Restricted picklist, Sort, Update

  • Description: The log category level for Visualforce. Includes information about Visualforce events, including serialization and deserialization of the view state or the evaluation of a formula field in a Visualforce page. The following are valid values.

This field is required.

  • Possible values:

    • NONE — None

    • INTERNAL — Internal

    • FINEST — Finest

    • FINER — Finer

    • FINE — Fine

    • DEBUG — Debug

    • INFO — Info

    • WARN — Warn

    • ERROR — Error

Wave 

  • Type: picklist

  • Required: No

  • Properties: Create, Filter, Group, Nillable, Restricted picklist, Sort, Update

  • Introduced: API version 39.0

  • Possible values:

    • NONE — None

    • INTERNAL — Internal

    • FINEST — Finest

    • FINER — Finer

    • FINE — Fine

    • DEBUG — Debug

    • INFO — Info

    • WARN — Warn

    • ERROR — Error

Workflow 

  • Type: picklist

  • Required: No

  • Properties: Create, Filter, Group, Nillable, Restricted picklist, Sort, Update

  • Description: The log category level for workflow rules. Includes information for workflow rules, such as the rule name and the actions taken. This field is required. The following are valid values.

  • Possible values:

    • NONE — None

    • INTERNAL — Internal

    • FINEST — Finest

    • FINER — Finer

    • FINE — Fine

    • DEBUG — Debug

    • INFO — Info

    • WARN — Warn

    • ERROR — Error

Usage 

To diagnose a functional issue or a performance problem, use the TraceFlag object to set up logging for yourself or for another user. The following options are available.

  • To set up logging for a specific user, set LogType to USER_DEBUG and TracedEntityId to the ID of the user. This option can be configured only for a user, not for an Apex class or Apex trigger.
  • To set up logging level overrides for an Apex class or trigger, set LogType to CLASS_TRACING and TracedEntityId to the ID of the Apex class or trigger. CLASS_TRACING trace flags override other logging levels, but don’t cause logs to be generated or persisted.

DID THIS ARTICLE SOLVE YOUR ISSUE?
Let us know so we can improve!