Answers.Body: <p>The <code>sites/default/files/civicrm/ConfigAndLog/</code> directory <em>should</em> contain your CiviCRM debug log (and some other files), provided that you're using Drupal, that your Drupal multisite directory is "default", and that the webserver is able to write to that directory. If you're not seeing that, you could:</p>
  
  <ul>
  <li>Check assumptions of what <code>CRM_Core_Error::debug_var()</code> will do with the input you're handing it (eg, check that if you pass in a string like <code>SNORK</code> instead of an array, you see that same word appear in a logfile). <code>::debug_var()</code> looks like it does print_r</li>
  <li><code>tail -f /path/to/*.log</code> might reveal which logfiles are being printed to when you hit that endpoint.</li>
  <li>Check the multisite directory is what you think (should be the same as your <code>settings.php</code> and <code>civicrm.settings.php</code>)</li>
  <li>Check again for typos (I see <code>defaut</code> in your question, but that's probably not it!)</li>
  <li>Check that the <code>sites/default/files/</code> directory and its descendant directories are writable to the webserver (typically user <code>www-data</code>, <code>httpd</code>, <code>_www</code> etc)</li>
  <li>Double check usage of the debug functions - there have been <a href="https://civicrm.stackexchange.com/questions/4867/whats-the-correct-way-to-log-debug-info-to-log">docs inconsistencies</a> which might lead you astray.</li>
  <li>Check out <a href="https://docs.civicrm.org/dev/en/latest/tools/debugging/#Debuggingfordevelopers-Logfiles" rel="nofollow noreferrer">CiviCRM docs on debugging</a></li>
  <li>There are other SE questions on debugging, eg <a href="https://civicrm.stackexchange.com/questions/6399/how-do-i-debug-civicrm-when-i-hit-a-blank-page-white-screen-fatal-error/6400#6400">tips on debugging when you can't view page output</a> also applies well to AJAX callbacks etc where you can't/shouldn't <em>modify</em> page output.</li>
  </ul>
  
  <p>CiviCRM has a more modern log interface available in <code>Civi::log()-&gt;debug('debug info');</code> (see <a href="https://civicrm.stackexchange.com/questions/3575/how-to-print-variable-debug-data-from-your-extension-php">How to print variable/debug data from your extension.php?</a> for an answer on that).</p>
  
  <p>If even that doesn't work, you could fall back to "stock" PHP debugging methods like <code>error_log()</code> and <code>file_put_contents()</code> if CiviCRM debugging isn't working.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-04-06T03:38:08.270Z
Answers.LastActivityDate: 2018-04-06T03:38:08.270Z
Answers.UserDisplayName: Chris Burgess
Body: <p>I want to debug a function on this file
  <a href="https://github.com/Project60/org.project60.banking/blob/9dc6bdcc486753f70948edfd4ea36df0eb9d2f86/extension/api/v3/BankingTransaction.php" rel="nofollow noreferrer">https://github.com/Project60/org.project60.banking/blob/9dc6bdcc486753f70948edfd4ea36df0eb9d2f86/extension/api/v3/BankingTransaction.php</a></p>
  
  <pre><code>/**
   * Analyses the given bank transactions
   *  used as AJAX call
   *
   * @param  list    list of bank_tx ids to process
   * @param  s_list  list of bank_tx_batch ids to process
   *
   * @return  array api result array
   * @access public
   */
  function civicrm_api3_banking_transaction_analyselist($params) {
  CRM_Core_Error::debug_var ('params', $params);
  
  }
  </code></pre>
  
  <p>The above function is invoked by button which has onclick event
  <a href="https://github.com/Project60/org.project60.banking/blob/9dc6bdcc486753f70948edfd4ea36df0eb9d2f86/extension/templates/CRM/Banking/Page/Review.tpl" rel="nofollow noreferrer">https://github.com/Project60/org.project60.banking/blob/9dc6bdcc486753f70948edfd4ea36df0eb9d2f86/extension/templates/CRM/Banking/Page/Review.tpl</a></p>
  
  <p>The code is as follows</p>
  
  <pre><code>  &lt;a id="analyseButton" onClick="analysePayment()" class="button"&gt;&lt;span title="{ts}Analyse (again){/ts}"&gt;&lt;div class="icon preview-icon ui-icon-refresh"&gt;&lt;/div&gt;{ts}Analyse (again){/ts}&lt;/span&gt;&lt;/a&gt;
  </code></pre>
  
  <p>But  I dont see anything on the log files, how can I get the variables
  I have checked it under sites/defaut/files/civicrm/ConfigandLog/
  I dont see any civicrm.log files or any other files ending with .log dont have value of debug which I have entered
  Also debug settings has been set to Yes</p>
  
Tags: <logs><civibanking><configandlog>
Title: How to debug variables inside function invoked via ajax call?
ThreadText: # How to debug variables inside function invoked via ajax call?
  
  (Asked by: username_0 on 2018-04-06)
  
  I want to debug a function on this file
  <https://github.com/Project60/org.project60.banking/blob/9dc6bdcc486753f70948edfd4ea36df0eb9d2f86/extension/api/v3/BankingTransaction.php>
  
  ```
  /**
   * Analyses the given bank transactions
   *  used as AJAX call
   *
   * @param  list    list of bank_tx ids to process
   * @param  s_list  list of bank_tx_batch ids to process
   *
   * @return  array api result array
   * @access public
   */
  function civicrm_api3_banking_transaction_analyselist($params) {
  CRM_Core_Error::debug_var ('params', $params);
  
  }
  
  ```
  
  The above function is invoked by button which has onclick event
  <https://github.com/Project60/org.project60.banking/blob/9dc6bdcc486753f70948edfd4ea36df0eb9d2f86/extension/templates/CRM/Banking/Page/Review.tpl>
  
  The code is as follows
  
  ```
    <a id="analyseButton" onClick="analysePayment()" class="button"><span title="{ts}Analyse (again){/ts}"><div class="icon preview-icon ui-icon-refresh"></div>{ts}Analyse (again){/ts}</span></a>
  
  ```
  
  But I dont see anything on the log files, how can I get the variables
  I have checked it under sites/defaut/files/civicrm/ConfigandLog/
  I dont see any civicrm.log files or any other files ending with .log dont have value of debug which I have entered
  Also debug settings has been set to Yes
  
  **Tags:** logs, civibanking, configandlog
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2018-04-06. Score: 1 | Accepted answer
  
  The `sites/default/files/civicrm/ConfigAndLog/` directory *should* contain your CiviCRM debug log (and some other files), provided that you're using Drupal, that your Drupal multisite directory is "default", and that the webserver is able to write to that directory. If you're not seeing that, you could:
  
  * Check assumptions of what `CRM_Core_Error::debug_var()` will do with the input you're handing it (eg, check that if you pass in a string like `SNORK` instead of an array, you see that same word appear in a logfile). `::debug_var()` looks like it does print\_r
  * `tail -f /path/to/*.log` might reveal which logfiles are being printed to when you hit that endpoint.
  * Check the multisite directory is what you think (should be the same as your `settings.php` and `civicrm.settings.php`)
  * Check again for typos (I see `defaut` in your question, but that's probably not it!)
  * Check that the `sites/default/files/` directory and its descendant directories are writable to the webserver (typically user `www-data`, `httpd`, `_www` etc)
  * Double check usage of the debug functions - there have been [docs inconsistencies](https://civicrm.stackexchange.com/questions/4867/whats-the-correct-way-to-log-debug-info-to-log) which might lead you astray.
  * Check out [CiviCRM docs on debugging](https://docs.civicrm.org/dev/en/latest/tools/debugging/#Debuggingfordevelopers-Logfiles)
  * There are other SE questions on debugging, eg [tips on debugging when you can't view page output](https://civicrm.stackexchange.com/questions/6399/how-do-i-debug-civicrm-when-i-hit-a-blank-page-white-screen-fatal-error/6400#6400) also applies well to AJAX callbacks etc where you can't/shouldn't *modify* page output.
  
  CiviCRM has a more modern log interface available in `Civi::log()->debug('debug info');` (see [How to print variable/debug data from your extension.php?](https://civicrm.stackexchange.com/questions/3575/how-to-print-variable-debug-data-from-your-extension-php) for an answer on that).
  
  If even that doesn't work, you could fall back to "stock" PHP debugging methods like `error_log()` and `file_put_contents()` if CiviCRM debugging isn't working.
  
  
  ---
  
  