为什么在写入标准输出时,PHP-FPM会在警告前添加前缀? [英] Why PHP-FPM prefixes a warning when writing to stdout?

查看:80
本文介绍了为什么在写入标准输出时,PHP-FPM会在警告前添加前缀?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用在Docker容器中运行基于Yii的PHP应用程序 href = https://hub.docker.com/_/php/ rel = nofollow noreferrer>官方php-fpm 图片。

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

docker容器的常见做法是将所有日志消息写入 stdout / stderr 。因此,我从容器中执行的代码基本上如下所示:

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);

不幸的是,PHP-FPM现在为我的所有日​​志消息添加了丑陋的警告:

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


[2016年3月21日14:10:02]警告:[池www]儿童12对标准输出说: 2016-03-21 14:10:02 [xxxx] [-] [-] [trace] [yii\base\Application :: bootstrap]使用yii\debug\Module :: bootstrap()的Bootstrap [
[2016年3月21日14 :10:02]警告:[池www]儿童12对标准输出说: 2016-03-21 14:10:02 [xxxx] [-] [-] [info] [yii\web\Session ::打开]会话开始
...

[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" ...

这是为什么,并且有一种方法可以防止PHP-FPM执行

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

更新:


  1. 我也打开了问题 / php rel = nofollow noreferrer> docker-library / php 项目站点。

  2. 它们已经包含了 catch_workers_output = yes 其配置。因此,这不是解决方案。

  3. 根据这些更改应该在PHP 7.3中解决该问题

  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


推荐答案

这是正确的。您正在运行php-fpm,并且错误日志来自php-fpm,而不是PHP。
您应该期望php-fpm log,而不是php log。幸运的是,php-fpm会将从PHP接收到的每个日志记录在其日志末尾。

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-FPM会在警告前添加前缀?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆