Answers.Body: <p>(<strong>Update</strong>) As of v4.7.0, the approaches below still work, but there's a better way to write to the log file using a <a href="https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md" rel="noreferrer">PSR-3</a> logger, e.g.:</p>
  
  <pre><code>Civi::log()-&gt;info('Hello, log!');
  Civi::log()-&gt;error('I'm sorry, {name}. I'm afraid I can't do that.', array(
    'name' =&gt; 'Stanley Kubrick',
  ));
  </code></pre>
  
  <p>See also:
  <a href="https://civicrm.org/blog/totten/the-static-is-dead-long-live-the-static" rel="noreferrer">https://civicrm.org/blog/totten/the-static-is-dead-long-live-the-static</a></p>
  
  <hr>
  
  <p>To write out to CiviCRM's <code>ConfigAndLog</code> folder, one can use either:</p>
  
  <pre><code>CRM_Core_Error::debug_log_message('hello log');
  CRM_Core_Error::debug_var('name', $var);
  </code></pre>
  
  <p>There's also an experimental <a href="https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md" rel="noreferrer">PSR-3</a> logger (<code>CRM_Utils_SystemLogger</code>) which writes out to the database (table <code>civicrm_system_log</code>), e.g.</p>
  
  <pre><code>$log = new CRM_Utils_SystemLogger();
  $log-&gt;info("hello log");
  $log-&gt;error("I'm sorry, {name}. I'm afraid I can't do that.", array(
    'name' =&gt; 'Stanley Kubrick',
  ));
  </code></pre>
  
  <p>If the debug statement is temporary (won't be committed/redistributed), then you can usually use CMS-specific functions (like Drupal devel's <code>dpm()</code> or Joomla's <code>JLog</code>).</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-06-27T19:00:03.433Z
Answers.LastActivityDate: 2016-05-05T20:37:35.837Z
Answers.LastEditDate: 2016-05-05T20:37:35.837Z
Answers.UserDisplayName: Tim Otten
Body: <p>I am trying to add a menu entry in the navigation, but this is causing the navigation menu to disappear, I am trying to debug the code but could not find any particular file.</p>
  
  <p>I have checked the following:</p>
  
  <ul>
  <li>Browser's Javascript Console</li>
  <li>CiviCRM logs from ConfigAndLog folder</li>
  <li>Apache2 log</li>
  </ul>
  
  <p>Is there anything else I should check? Is there any way I can print the data in the <code>extension_civicrm_navigationMenu(&amp;$params)</code> function?</p>
  
Tags: <extension><developer><gsoc><debugging>
Title: How to print variable/debug data from your extension.php?
ThreadText: # How to print variable/debug data from your extension.php?
  
  (Asked by: username_0 on 2015-06-27)
  
  I am trying to add a menu entry in the navigation, but this is causing the navigation menu to disappear, I am trying to debug the code but could not find any particular file.
  
  I have checked the following:
  
  * Browser's Javascript Console
  * CiviCRM logs from ConfigAndLog folder
  * Apache2 log
  
  Is there anything else I should check? Is there any way I can print the data in the `extension_civicrm_navigationMenu(&$params)` function?
  
  **Tags:** extension, developer, gsoc, debugging
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2015-06-27. Score: 8 | Accepted answer
  
  (Update) As of v4.7.0, the approaches below still work, but there's a better way to write to the log file using a PSR-3 logger, e.g.:
  Civi::log()->info('Hello, log!');
  Civi::log()->error('I'm sorry, {name}. I'm afraid I can't do that.', array(
    'name' => 'Stanley Kubrick',
  ));
  
  See also:
  https://civicrm.org/blog/totten/the-static-is-dead-long-live-the-static
  
  To write out to CiviCRM's ConfigAndLog folder, one can use either:
  CRM_Core_Error::debug_log_message('hello log');
  CRM_Core_Error::debug_var('name', $var);
  
  There's also an experimental PSR-3 logger (CRM_Utils_SystemLogger) which writes out to the database (table civicrm_system_log), e.g.
  $log = new CRM_Utils_SystemLogger();
  $log->info("hello log");
  $log->error("I'm sorry, {name}. I'm afraid I can't do that.", array(
    'name' => 'Stanley Kubrick',
  ));
  
  If the debug statement is temporary (won't be committed/redistributed), then you can usually use CMS-specific functions (like Drupal devel's dpm() or Joomla's JLog).
  
  
  ---
  
  