Symfony生产日志

问题描述 投票:0回答:1

在Symfony 3中,无论如何我可以将所有错误写入生产日志,而无需设置调试模式?错误包括http 500错误或应用程序错误或由于错误标志在生产时设置为false而被静音的php错误。

生产的当前日志配置是

monolog:
    handlers:
        main:
            type: stream
            path: "%kernel.logs_dir%/%kernel.environment%.log"
            level: info
            channels: [!request, !event, !translation, !kernel, !security, !php, !snc_redis]
       php:
            type: stream
            path: "%kernel.logs_dir%/%kernel.environment%_php.log"
            level: warning
            channels: [php]
php symfony monolog
1个回答
1
投票

您可以使用默认的生产设置(取自monolog-bundle recipe):

monolog:
    handlers:
        main:
            type: fingers_crossed
            action_level: error
            handler: nested
            excluded_404s:
                # regex: exclude all 404 errors from the logs
                - ^/
        nested:
            type: stream
            path: "%kernel.logs_dir%/%kernel.environment%.log"
            level: debug

此配置发生的情况是Monolog在请求期间缓冲所有消息,但仅在出现错误时将它们写入日志。这样,您就不会一直使用嘈杂的调试和信息消息“充斥”您的日志。只有在请求期间发生错误时,才会获得完整的日志信息。

© www.soinside.com 2019 - 2024. All rights reserved.