【问题标题】:Log from Symfony to php://stdout shows log messages in my console commands从 Symfony 到 php://stdout 的日志在我的控制台命令中显示日志消息
【发布时间】:2019-06-24 14:47:37
【问题描述】:

我正在运行一个带有官方 php:7.3.3-apache 标签的 docker 容器。我安装了启用独白的 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 ......

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

【问题讨论】:

  • 嗨!你终于找到解决这个问题的方法了吗?谢谢!

标签: php symfony logging


【解决方案1】:

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

【讨论】:

  • 已经试过了,用php 7.3.3的docker镜像他们都去同一个地方
猜你喜欢
  • 2022-01-16
  • 2019-06-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-06-25
  • 1970-01-01
相关资源
最近更新 更多