Why PHP-FPM prefixes a warning when writing to std

2019-06-14 21:20发布

问题:

I try to run a Yii based PHP application in a Docker container using the official php-fpm image.

It's common practice for docker containers to write all log messages to stdout / stderr. So I do the same from my container with a code that basically looks like this:

$fp = @fopen('php://stdout','w');
fwrite($fp, $message);
fclose($fp);

Unfortunately PHP-FPM now prefixes all my log messages with ugly warnings:

[21-Mar-2016 14:10:02] WARNING: [pool www] child 12 said into stdout: "2016-03-21 14:10:02 [x.x.x.x][-][-][trace][yii\base\Application::bootstrap] Bootstrap with yii\debug\Module::bootstrap()" [21-Mar-2016 14:10:02] WARNING: [pool www] child 12 said into stdout: "2016-03-21 14:10:02 [x.x.x.x][-][-][info][yii\web\Session::open] Session started" ...

Why is this and is there a way to prevent PHP-FPM from doing this?

UPDATE:

  1. I've also opened an issue at the docker-library/php project site.
  2. They already include the catch_workers_output = yes in their configuration. So that's not the solution.
  3. According to these changes the problem should be fixed in PHP 7.3

回答1:

It is correct. you are running php-fpm and error logs are from php-fpm , not from PHP . you should expect php-fpm log , not php log. fortunately php-fpm will write every log that received from PHP in end of its logs.



标签: php docker