从Symfony登录到php:// stdout在我的控制台命令中显示日志消息

时间:2019-06-24 14:47:37

标签: php symfony logging

我正在运行带有官方php:7.3.3-apache标签的Docker容器。我已安装启用了Monolog的Symfony 4。

通常,monolog使用var/dev.logvar/prod.logvar/test.log来写入其日志,但是您可以将配置更改为php://stdoutphp://stderr来发送日志到Docker容器。

我的monolog.yaml文件如下:

monolog:
    handlers:
        main:
            type: stream
            path: "php://stdout"
            level: debug
            channels: ["!event"]
        console:
            type: console
            process_psr_3_messages: false
            channels: ["!event", "!doctrine", "!console"]

它会从网站正确发送日志,但是当我使用php bin/console命令运行命令时,我会在屏幕上显示日志,例如:

$ 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 ......

如何从网站和命令正确登录?

1 个答案:

答案 0 :(得分:0)

php://stdout更改为php://stderr