Symfony logs to stdout inside Docker container

后端 未结 2 614
刺人心
刺人心 2020-12-13 00:37

I\'m building a docker image for a Symfony application. In this image, I want to stream the Symfony logs to stdout. So, similar to how nginx logs are configured, I added thi

2条回答
  •  离开以前
    2020-12-13 01:27

    My config to get all php infos / warnings / errors to docker log (I am using php:7.1-apache image):

    php.ini

    log_errors = On
    error_reporting = E_ALL | E_STRICT
    error_log = /dev/stderr
    

    Symfony config

    # app/config/config_prod.yml
    monolog:
    handlers:
        main:
            type: group
            members: [logfile, dockerlog]
        logfile:
            type: stream
            path: "%kernel.logs_dir%/%kernel.environment%.log"
            level: debug
            channels: ['!event', '!doctrine']
        dockerlog:
            type: stream
            path:  "php://stderr"
            level: debug
            channels: ['!event', '!doctrine']
    

    troubleshooting:

    • check symfony environment (prod/dev/test)
    • clear symfony cache maybe
    • rebuild container, if you copy php.ini in dockerfile

提交回复
热议问题