Dashboard > CiviCRM Documentation > ... > 8. FAQ > Debug Tools
Debug Tools Log In | Sign Up   View a printable version of the current page.

 Contents
  Documentation Home

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

Added by Judy Halllman , last edited by David Greenberg on Mar 20, 2008  (view change)
Labels: 
(None)

Recently Updated  |  Documentation Credits

Powered by a free Atlassian Confluence Open Source Project License granted to CiviCRM . Evaluate Confluence today.
Powered by Atlassian Confluence 2.7.1, the Enterprise Wiki. Bug/feature request - Atlassian news - Contact administrators