Skip to end of metadata
Go to start of metadata
CiviCRM Documentation

This page refers to outdated version of CiviCRM. Check current version of documentation.

What debugging tools are available in CiviCRM?

Debugging from your browser

CiviCRM comes with several built-in debugging tools. You will need to enable the debug and backtrace options to use these tools. Once enabled, you invoke the tools via URL parameters.

You can enable debugging in: Administer CiviCRM >> Global Settings >> Debugging

Available debugging tools are:

  • Smarty Debug Window: Loads all variables available to the current page template into a pop-up window. To trigger, add &smartyDebug=1 to any CiviCRM URL query string.
  • Session Reset: Resets all values in your client session. To trigger, add &sessionReset=2
  • Directory Cleanup: Empties template cache and/or upload file folders.
    • To empty template cache (civicrm/templates_c folder), add &directoryCleanup=1
    • To remove temporary upload files (civicrm/upload folder), add &directoryCleanup=2
    • To cleanup both, add &directoryCleanup=3.

You will see a page of warnings and error messages immediately after running directory cleanup. This is normal and expected — the errors will disappear as soon as you navigate to a new CiviCRM page.

WARNING: Do not leave debugging enabled by default as it can be used to expose configuration information to unauthorized browsers.

Debugging in code

The CiviCRM framework includes a few useful debugging methods which you can insert into any codebase file to get more information about what's happening in a particular function or workflow:

  • CRM_Core_Error::debug('variable_name', $variable) - readable dump of the referenced $variable to the screen
  • CRM_Core_Error::debug_var ('variable_name', $variable) - readable dump of referenced $variable to the screen and to CiviCRM.log. Add 3rd parameter false if you don't want screen output.
  • CRM_Core_Error::debug_log_message( $message, $out = false ) - dump message to CiviCRM.log. If second param is true, also echo to screen.

All logging output is written to CiviCRM.log in the configured "Temporary Files" directory (see Administer CiviCRM » Global Settings » Directories). By default this is:

<drupal root directory>/files/civicrm/upload/CiviCRM.log

Some PHP functions that may also be useful for debugging include:

  • $args=func_get_args(); - get all argument values passed in to function
  • flush(); - flush output to browser
Labels
  • None

Creative Commons License
Except where otherwise noted, content on this site is licensed under a Creative Commons Attribution-Share Alike 3.0 United States Licence.