Newer Version Available

This content describes an older version of this product. View Latest

TraceFlag

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

Supported SOAP API Calls

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

Supported REST API HTTP Methods

Query, GET, POST, PATCH, DELETE

Fields

Field Name Details
ApexCode
Type
picklist
Properties
Create, Filter, Group, 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.
  • NONE
  • ERROR
  • WARN
  • INFO
  • DEBUG
  • FINE
  • FINER
  • FINEST

This field is required.

ApexProfiling
Type
picklist
Properties
Create, Filter, Group, 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.
  • NONE
  • ERROR
  • WARN
  • INFO
  • DEBUG
  • FINE
  • FINER
  • FINEST

This field is required.

Callout
Type
picklist
Properties
Create, Filter, Group, 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.
  • NONE
  • ERROR
  • WARN
  • INFO
  • DEBUG
  • FINE
  • FINER
  • FINEST

This field is required.

Database
Type
picklist
Properties
Create, Filter, Group, 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.
  • NONE
  • ERROR
  • WARN
  • INFO
  • DEBUG
  • FINE
  • FINER
  • FINEST

This field is required.

DebugLevelId
Type
reference
Properties
Create, Filter, Group, Nillable, Sort, Update
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.
ExpirationDate
Type
dateTime
Properties
Create, Filter, 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
Properties
Create, Filter, Group, Restricted picklist, Sort
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.

ScopeId
Type
reference
Properties
Create, Filter, Group, Nillable, Sort, Update
Description

Deprecated. This field is available in API version 34.0 and earlier.

A reference to a user. This field is used with the TracedEntityID field.

  • When the value is user, the actions of the user or entity specified by TracedEntityID are traced to the system log at the described level. System logs are visible only to you. Use this scope for class-level filtering. If there are both user and entity-level flags, the user flags take precedence until a method from a class with an entity trace flag is entered. When the method returns, the user trace flags are restored.
  • When the value is emptyid, the user’s actions are traced to the org’s debug log at the described level. Debug logs are visible to all administrators. This option is only available if TracedEntityID references a user (not an Apex class or Apex trigger). The variable emptyid can be the value 0000000000000000 or null.

The scope defined here is reflected in the ApexLog Location field.

StartDate
Type
dateTime
Properties
Create, Filter, Group, Nillable, Sort, Update
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
Properties
Create, Filter, Group, 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.
  • NONE
  • ERROR
  • WARN
  • INFO
  • DEBUG
  • FINE
  • FINER
  • FINEST

This field is required.

TracedEntityId
Type
reference
Properties
Create, Filter, Group, Sort, Update
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
Properties
Create, Filter, Group, 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.
  • NONE
  • ERROR
  • WARN
  • INFO
  • DEBUG
  • FINE
  • FINER
  • FINEST

This field is required.

Visualforce
Type
picklist
Properties
Create, Filter, Group, 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.
  • NONE
  • ERROR
  • WARN
  • INFO
  • DEBUG
  • FINE
  • FINER
  • FINEST

This field is required.

Workflow
Type
picklist
Properties
Create, Filter, Group, 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.
  • NONE
  • ERROR
  • WARN
  • INFO
  • DEBUG
  • FINE
  • FINER
  • FINEST

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.