2

A PHP 5.5 web app running in Apache does not take the value of log_errors_max_len when logging with error_log(). The output is always trimmed at the same length if the message length is too large no matter what the value of log_errors_max_len is set to (0, 1024, 10000, ...).

I have run the following script (via the browser) and the output in /var/log/apache2/error.log is allways a 8107 characters string. The value displayed for log_errors_max_len is allways the correct one setted with ini_set('log_errors_max_len', XXXX);.

<?php
error_reporting(E_ALL|E_STRICT);
ini_set('display_errors',1);
ini_set('log_errors',1);
ini_set('log_errors_max_len',2000);

$msg = '';
$msg2 = '';
for ($i = 0; $i < 1000; $i++) {
    $msg2 = $i.'_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
    $msg = $msg.substr($msg2, 0, 100);
}
error_log(print_r($msg, true), 0);
error_log(ini_get('log_errors_max_len'), 0);
?>

On the other side the same script running in CLI and logging to stderr displays allways the whole untrimmed string, no matter how small is the value of log_erros_max_len.

Following this reference PHP Error Log Ignores log_errors_max_len Setting I get to a BUG report in PHP with Status "Not a bug" and with no more relevant info.


Ubuntu 14.04

Apache 2.4.7

PHP 5.5.9

Community
  • 1
  • 1
David Casillas
  • 1,801
  • 1
  • 29
  • 57

1 Answers1

1

I have the same problem using Nginx instead of Apache, and the same Ubuntu and PHP versions. Digging in the PHP documentation I found that the log_errors_max_len setting does not affect the error_log() function, and aparently theres is nothing to do about it.

Leopoldo Sanczyk
  • 1,529
  • 1
  • 26
  • 28