25.4.3.4 Adding Custom Debug Messages

Add custom debug messages with APEX_DEBUG.INFO when needed.

When natively available debug information does not suffice, you can add your own by calling the INFO procedure in the APEX_DEBUG package. Use it in an Execute Code type:
  • page process in a page,
  • action in a task definition or automation, or
  • activity in a workflow.

To log a message, use INFO as shown below. Consider starting your debug message with a prefix like ### that's easy to search for in the debug trace log. By surrounding the %s token with parentheses, a null value is easier to see.

apex_debug.info('### somevar=(%s), someexpr=(%s), anotherexpr=(%s)',
                :SOMEVAR,
                some_expression,
                another_expression);
The message can contain up to ten %s replacement tokens that are substituted sequentially by the corresponding additional values you pass as additional parameters. Alternatively the message can contain %0, %1, …, %9 to reference the additional parameter values. For example, the following produces the same message as above:
apex_debug.info('### somevar=(%2), someexpr=(%0), anotherexpr=(%1)',
                some_expression,
                another_expression,
                :SOMEVAR);

The message, including substituted values, can be up to 32727 characters. However, messages exceeding 4000 characters appear "chunked" in the debug viewer. By default, the parameter values are truncated at 1000 characters each. Pass the optional p_max_length parameter to specify longer values.

Tip:

If your message substitution token appear to be ignored, check the message string more closely. It's common to accidentally type % alone instead of the required %s or %0, %1, etc.