1

I am using the image richarvey/nginx-php-fpm:latest (1.5.2) and I started a container based on this image and executed /bin/bash inside.

There I :

  • have installed composer
  • created a new symfony4 project using composer create-project symfony/website-skeleton my-project
  • have edited my-project/config/packages/dev/monolog.yaml to set :

    monolog:
        handlers:
            main:                   
                type: stream  
                path: 'php://stderr' 
                level: debug        
                channels: ["!event"]
    
  • got the IP of my docker image using docker inspect

  • and dump my container logs using docker logs -f <my container>

When I load http://<my container ip>/my-project/public, I don't see the symfony debug logs in my container logs output.

Note : I see the nginx logs.

jobou
  • 1,823
  • 2
  • 18
  • 28
  • _When I load `http:///my-project/public`, I don't see the symfony debug logs in my container logs output._ Why do you expect logs to be added? It looks like you're trying to see files in`public`, and files are probably served by your server, without Symfony. – A.L Jun 24 '18 at 13:47
  • @A.L : I don't understand your comment. When you have just done a new SF install, you have a demo route served on `/` and when you access it, you have debug logs output about which SF route is matched and so on ... Note : it is a SF4 install so the `public` folder has an `index.php` file and not only the assets. – jobou Jun 24 '18 at 18:00
  • Sorry, I forgot that `public` is different on Symfony4. Could you please share the commands you use to launch the container? I would like to try by myself. – A.L Jun 24 '18 at 18:13
  • 1
    I am using a simple docker run command. Something like this : `docker run -d --name testfpm richarvey/nginx-php-fpm:latest` command. Then I do the steps described in my ticket inside the container ``docker exec -it testfpm -- /bin/bash` – jobou Jun 25 '18 at 10:25
  • How did you have the idea to use `path: 'php://stderr'`? Could you please share a link that explain this usage? Maybe something is missing in this configuration. – A.L Jun 26 '18 at 07:56
  • I followed this : https://stackoverflow.com/questions/38499825/symfony-logs-to-stdout-inside-docker-container and a bunch of other github issues and other SO questions. – jobou Jun 26 '18 at 08:05
  • Did you configured the supervisor log level too? – A.L Jun 26 '18 at 08:11
  • No I did not change the image settings for this tool. I attached mysql to the container, stopped fpm in the supervisor and run the same command in the console and I see the logs to the standard or error output. However supervisor does not seem to catch it and redirect it to its own output in order form them to be visible by docker. – jobou Jun 26 '18 at 08:24

1 Answers1

0

One of my coworker found the solution and the docker image maintainer implemented it :

https://gitlab.com/ric_harvey/nginx-php-fpm/commit/51bbf4e04f61873dfeae69e943fcdf0a900f2589#8ad4b94617a62f898119a66a878f8035b8605d13

As php-fpm is run in nodaemonized mode, you need to set the --force-stderr flag which "Force output to stderr in nodaemonize even if stderr is not a TTY."

https://www.gsp.com/cgi-bin/man.cgi?section=8&topic=php-fpm

jobou
  • 1,823
  • 2
  • 18
  • 28