tags:

views:

61

answers:

1

When reading over my error logs I notice that long parameters (such as SQL strings) are truncated in the Exception trace. Here's an example:

FR_Model.php(204): FR_Base->query('INSERT INTO pos...', Array)

I'd like an easy way to echo the full parameter without having to roll my own Exception subclass. TIA.

+1  A: 

Check your log_errors_max_len PHP setting. From php.net:

log_errors_max_len integer - changeable: PHP_INI_ALL

Set the maximum length of log_errors in bytes. In error_log information about the source is added. The default is 1024 and 0 allows to not apply any maximum length at all. This length is applied to logged errors, displayed errors and also to $php_errormsg.

To test: (via this Bogus bug)

<?php
error_reporting(E_ALL|E_STRICT);
ini_set('display_errors',0);
ini_set('log_errors',1);
ini_set('log_errors_max_len','0'); //change this value
ini_set('html_errors',0);

function deepTrace($a, $b, $c) {
    if ($c < 50) {deepTrace($a, $b, $c+1);} else {throw new Exception('Example exception that together with the trace is over 1024 bytes.');}
}
deepTrace('example','function',0);
?>

If changing log_errors_max_len in this sample code to 0 doesn't work, but changing it to a number larger than 1024 has some effect, then you are almost certainly loading a zend_extension somewhere that is overriding PHP's standard behavior, such as Zend Optimizer, Zend Debugger, Xdebug, etc.

Try grep -r zend_extension /etc/php.* to locate any extensions in use; if it finds a matching line that isn't commented out, there's your culprit.

rymo
Setting this to 0 didn't work. Perhaps this only pertains to errors, and not exceptions?
Arms