-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Logs to stdout get prefixed with warning in php-fpm image #207
Comments
That should be configurable by putting a config file in |
@yosifkit Not sure what you mean by |
@yosifkit Ok found it in the example pool config. Weird that this is not really documented anywhere else - at least Google didn't find it. But I don't think that this solves the issue. Please note that PHP-FPM adds the prefix WARNING: [pool www] child 12 said into stdout: to my log messages. It also splits up the message on line breaks. So if you had a single message spanning several lines, you'll end up with several log entries. |
I found it on https://serverfault.com/questions/574880/nginx-php-fpm-error-logging, though not sure we can get rid of the fpm extra warning parts. Looking at how Heroku "fixed" it gives me little hope. There is also a post I found in a google group. I saw your stackoverflow post, but I think the excessive logging might be in php-fpm code itself. 😞 |
I've created a bug report at php.net: https://bugs.php.net/bug.php?id=71880 |
@mikehaertl any progress on this issue? It is ugly seeing |
@phillydogg28 Unfortunately not. The PHP issue mentioned above has not really got much attention as it seems. It would probably help if you cast a vote there. |
A workaround is to add the following lines on your FROM php:7.1-fpm
# Workaround https://bugs.php.net/bug.php?id=71880
ENV LOG_STREAM="/tmp/stdout"
RUN mkfifo $LOG_STREAM && chmod 777 $LOG_STREAM
CMD ["/bin/sh", "-c", "php-fpm -D | tail -f $LOG_STREAM"] Then on your PHP code you have a Finally there are some scenarios does not require this workaround like #docker-compose.yml
version: "2"
services:
MyWorker:
command: php bin/worker.php
image: image-with-php-fpm-and-previous-workaround
environment:
LOG_STREAM: php://stdout |
Notice PHP-FPM does not only add a prefix, it also truncate the length of the message which end in a loss of information. Workarounds based on |
@Maks3w Thanks, at least that's a solution for those who can't wait that this finally gets fixed in PHP. Though I'd prefer something where I don't have to change the |
How does |
See also this php/php-src/pull/1076 |
@schmunk42 indeed that would be a problem as the exit status code is lost. A correct
|
Given that this is an issue with PHP-FPM itself (and not something we can easily fix in the image), I'm going to close. I would recommend that folks interested in this topic (and whether it ever reaches a conclusion) follow and/or contribute to the upstream issue: https://bugs.php.net/bug.php?id=71880 👍 ❤️ |
Thanks for the link. How do I "follow" or "subscribe" to issues on bugs.php.net? On other bugtrackers, I would expect to be able to register an account and then have some "subscribe" or "CC" field appear. But in order to login to bugs.php.net, I apparently need an @php.net account / email address, which I don't have. |
I'm not sure if there's a way to officially subscribe without a php.net address -- I simply meant that folks should look there for updates. I believe the RSS feeds are the only way for non-php.net holders to subscribe: https://bugs.php.net/rss/bug.php?id=71880&format=rss2 |
Oh, and of course as I send that, I find a "subscribe" form on https://bugs.php.net/bug.php?id=71880&edit=3 (enter your email, solve a simple math problem, click subscribe) |
In case someone missed it, it should also be mentioned that you can also upvote the issue on that page https://bugs.php.net/bug.php?id=71880 |
Thanks! That was about the only place, where I did not look. |
You are amazing, @Maks3w !! |
@Maks3w If you got a container with tty and want to enter it, that is not possible if you have tail as a command. In our case that even broke our CI... |
I'm getting |
As of PHP 7.3 we finally use STDOUT and STDERR properly in our containers, this disables the '[pool %s] child %d said into %s: \"%s\' format. More info: - php/php-src#2458 - https://bugs.php.net/bug.php?id=71880 - docker-library#207
php 7.3 is released (changelog) - it looks very promising with regards to logging improvements when running in docker:
I didn't get to try 7.3 yet, does it fix this Github issue and make our lives easier? |
Just add this to [php]
error_log = /proc/1/fd/2 |
I confirm : using php-7.3 with |
I suppose we could enable it by default for 7.3 release, right? |
Just to thread the needle, see #725 which did exactly that. 👍 |
@mpyw with this command |
@mpyw with this command |
@mpyw It 's confused it can not run in foreground in my case without Currently, our team use 7.2.x. |
@addozhang My (deleted) comment was completely wrong, sorry. It seemed to be implicitly depending on the daemonization option in configuration file. |
Updated and deleted some comments |
@Maks3w Great workaround, however I seem to have issues on managing the container state. If php-fpm crashes, the container will remain running since the |
The problem with above's solutions is that if you run anything other than |
For someone stumbling upon this ticket, php 7.3 have a new directive to remove all the extraneous text from log output:
|
For PHP 7.3: [www]
decorate_workers_output = no For PHP 7.2: |
Yeah, 👍 to fix this once and for all, your PHP-FPM has to be >7.3 cause they added a fix and some configuration to prevent this to happen. And then add this lines: on php.ini or any overrides you have log_errors_max_len = 8192 on the fpm configuration pool overrides.conf [global]
; this prevents a bigger json to be splitted into multiple lines
log_limit = 8192
[www]
; this will void the warning messages on the log output
decorate_workers_output = no Finally I can see my logs in Datadog as they should be :) |
As of PHP 7.3 we finally use STDOUT and STDERR properly in our containers, this disables the '[pool %s] child %d said into %s: \"%s\' format. More info: - php/php-src#2458 - https://bugs.php.net/bug.php?id=71880 - docker-library/php#207
As of PHP 7.3 we finally use STDOUT and STDERR properly in our containers, this disables the '[pool %s] child %d said into %s: \"%s\' format. More info: - php/php-src#2458 - https://bugs.php.net/bug.php?id=71880 - docker-library/php#207
As of PHP 7.3 we finally use STDOUT and STDERR properly in our containers, this disables the '[pool %s] child %d said into %s: \"%s\' format. More info: - php/php-src#2458 - https://bugs.php.net/bug.php?id=71880 - docker-library/php#207
I try to run a [Yii based PHP application][1] in a Docker container using the php-fpm image. As usual for docker containers I write all log messages to
stdout
/stderr
with some code like this:Unfortunately PHP-FPM now prefixes all my log messages with ugly warnings:
Can we prevent this somehow or is there a better way to log app output?
The text was updated successfully, but these errors were encountered: