I am running a docker container with the official php:7.3.3-apache tag. I have Symfony 4 installed with monolog enabled.
Normally monolog uses the var/dev.log, var/prod.log and var/test.log to write its logs but you can change the configuration to php://stdout or php://stderr to send the logs to the docker container.
My monolog.yaml file looks like:
monolog:
handlers:
main:
type: stream
path: "php://stdout"
level: debug
channels: ["!event"]
console:
type: console
process_psr_3_messages: false
channels: ["!event", "!doctrine", "!console"]
And it sends the logs properly from the website, however when I run a command using the php bin/console command I get the logs right on the screen, for example:
$ php bin/console cache:clear
[2019-06-24 14:29:19] doctrine.DEBUG: SELECT h0_.id AS id_0, h0_.name AS name_1, h0_.value AS value_2, h0_.description AS description_3 FROM hpa_configuration h0_ [] []
[2019-06-24 14:29:19] php.INFO: User Deprecated: The "Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand" class is deprecated since Symfony 4.2, use "Symfony\Component\Console\Command\Command" with dependency injection instead. {"exception":"[object] (ErrorException(code: 0): User Deprecated: The \"Symfony\\Bundle\\FrameworkBundle\\Command\\ContainerAwareCommand\" class is deprecated since Symfony 4.2, use \"Symfony\\Component\\Console\\Command\\Command\" with dependency injection instead. at /var/www/html/hpa/vendor/symfony/framework-bundle/Command/ContainerAwareCommand.php:18)"} []
// Clearing the cache for the dev environment with debug ......
How can I log properly from the website and commands?