I have a PHP/Symfony app running in Docker which uses Monolog to log to stdout/stderr. This all works great, except when running Symfony console commands inside a container.
monolog:
handlers:
stdout:
type: filter
handler: stdout_unfiltered
max_level: notice
channels: ['!event']
stdout_unfiltered:
type: stream
level: debug
path: 'php://stdout'
stderr:
type: stream
level: warning
channels: ['!event']
path: 'php://stderr'
console:
type: console
channels: ['!console', '!doctrine', '!event']
process_psr_3_messages: false
The problem is that whenever a command is executed, the "stdout", "stderr" and "console" handlers log to the current terminal process. This causes the console output to be messed up, and docker logs
not to contain the log entries: https://i.stack.imgur.com/NRris.png.
Would there be an easy way to always send the logging output to the php-fpm (or any worker) process?