Multiple error_log () messages on one line in the error log

I have this PHP code:

error_log('my message 1');
....
error_log('my message 2');
...
error_log('my message 3');

This creates a single line in apache error_log with all messages:

[Wed Nov 13 17:24:55.880399 2013] [proxy_fcgi:error] [pid xx] [client xxx] AH01071: Got error 'PHP message: my message 1\n'PHP message: my message 2\n'PHP message: my message 3

My configuration:

Apache 2.4
PHP : 5.4
PHP-FPM with proxypassmatch directive.

My question is: why are the messages on the same line and how do I have one line per message?

Thank you for your responses.

EDIT

One line for each message should look like this:

[Wed Nov 13 17:24:55.880399 2013] [proxy_fcgi:error] [pid xx] [client xxx] AH01071: Got error 'PHP message: my message 1'
[Wed Nov 13 17:24:55.880399 2013] [proxy_fcgi:error] [pid xx] [client xxx] AH01071: Got error 'PHP message: my message 2'
[Wed Nov 13 17:24:55.880399 2013] [proxy_fcgi:error] [pid xx] [client xxx] AH01071: Got error 'PHP message: my message 3'
+4
source share
2 answers
error_log("error message \r\n");

PHP ignores special ASCII characters in single quotes (it displays it as separate characters), you need to use double quotes.

In addition: You must open the php.ini file, the one located in the / etc / php 5 / apache2 / folder, and pass the directive error_logto point to the file.

, Apache . chown www-data:www-data /var/www/somefile.log

undefined, syslog, .

: , .

:

try{
  ob_start();
  doSomething($userInput);
  ob_end_flush();
}
catch(Exception $e){
 error_log($e->getMessage());
}

function doSomething($data = null){
  if($data === null){
    throw new Exception("Data is required");
  }
  else{
    //do something
  }

}
+1

\r\n

error_log("my message 1\r\n");
....
error_log("my message 2\r\n");
...
error_log("my message 3\r\n");
0

All Articles