Skip to content
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 (access.log, error.log) to stdErr #358

Closed
tchiotludo opened this issue Jan 2, 2017 · 8 comments
Closed

Logs (access.log, error.log) to stdErr #358

tchiotludo opened this issue Jan 2, 2017 · 8 comments

Comments

@tchiotludo
Copy link

This configuration seems normal to everyone :

[global]
error_log = /proc/self/fd/2 

; if we send this to /proc/self/fd/1, it never appears
access.log = /proc/self/fd/2

But this really sucks, the access log is merged with the error log.
The fpm config doesn't allow us to catch true error (error output on catch error), the fpm log info & the access log.

I can see that the the comment is true, if you try anything else that is docker supported (/dev/stdout, ...) doesn't seems to work.
But I really wonder what is the reason since other docker image works well. I really want to report the bug to the right repositories.

I've the impression that is fpm related bug but I can't find any issue reported about this.
Any help will be really appreciate.

@gajus
Copy link

gajus commented Jan 3, 2017

I am not even getting this far... I am not able to get logs in the console at all.

I can see that php-fpm.d/docker.conf is being created, and this is my php.ini configuration.

However, unless I add echo "php_admin_flag[log_errors] = On">>/usr/local/etc/php-fpm.conf to my Dockerfile, I am not getting any logs.

Is there something I am overlooking?

gajus added a commit to gajus/sinonimai.lt that referenced this issue Jan 3, 2017
Need to keep an eye on docker-library/php#358 to find out what is the reason that the `php_admin_flag[log_errors]` is necessary.
@ghost
Copy link

ghost commented Jan 4, 2017

@ssssaaa111

@tchiotludo
Copy link
Author

@gajus : try to replace
error_log = /var/log/php-errors.log by error_log = /dev/stderr and it must be working

logging to docker must be to files like /dev/stderr, /dev/stdout, /proc/self/fd/2, /proc/self/fd/1 in by capture by docker daemon

@tianon
Copy link
Member

tianon commented Jan 6, 2017

Yeah, I'd love to have a decent fix for this, but we haven't found one yet -- I'm guessing that the reason /proc/self/fd/1 (and /dev/stdout, which is a symlink to /proc/self/fd/1) doesn't work is that php-fpm likely closes STDOUT as part of its own startup routines. 😞

@tchiotludo
Copy link
Author

created a bug report on php : https://bugs.php.net/bug.php?id=73886, wait and see

@tchiotludo
Copy link
Author

for information : php/php-src#2310
It's being discussed internally with a patch available.
@tianon you have right, the patch show that the STDOUT is closed, and the patch don't close it anymore.
Hope this will be accepted 🤞

@tianon
Copy link
Member

tianon commented Dec 22, 2017

Closing since this is a bug in upstream's handling of stdout, not something we can reasonably fix in the image.

I'd love to see a PR which adds https://bugs.php.net/bug.php?id=73886 and php/php-src#2310 as context to our existing comment for future reference (and so we have an obvious place to go look for when this can be adjusted), though! ❤️

ala:

; if we send this to /proc/self/fd/1, it never appears
; see https://bugs.php.net/bug.php?id=73886
; and https://github.com/php/php-src/pull/2310
access.log = /proc/self/fd/2

@josuealcalde
Copy link

josuealcalde commented Nov 12, 2021

Hi

I have been struggling with this bug to have access_log in stdout and I think I have found a good solution. I don't know if it is enough to go upstream.

The idea is put access.log to /proc/self/fd/3 and redirect /proc/self/fd/3 to sdout.

So, I have this in my php-fpm-conf

access.log=/proc/self/fd/3
And i have added this to the docker-php-entrypoint:

exec 3> /dev/stdout

I already have a custom www.conf file for my php-fpm configuration, so it has not been a big deal to change the access.log.

For the docker-php-entrypoint I have used sed in my dockerfile:

RUN sed -i s/exec\ \"\$@\"\/exec\ 3\>\ \\/dev\\/stdout\\nexec\ \"\$@\"/ /usr/local/bin/docker-php-entrypoint

Maybe this is a bit tricky to go upstream, but it can help people to solve this problem by their own.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants