【问题标题】:how to disable security.info and security.debug in monolog symfony2 logging如何在独白 symfony2 日志记录中禁用 security.info 和 security.debug
【发布时间】:2015-04-15 21:19:44
【问题描述】:

我经常看到一堆以下日志:

[2015-02-15 09:08:16] request.INFO: Matched route "AppMainBundle_daftar_toko_province" (parameters: "_controller": "App\MainBundle\Controller\ZHomepageController::daftarTokoAction", "provinceName": "DKI JAKARTA", "_route": "AppMainBundle_daftar_toko_province") [] []
[2015-02-15 09:08:16] security.INFO: Populated SecurityContext with an anonymous Token [] []
[2015-02-15 09:08:16] security.DEBUG: Write SecurityContext in the session [] []

在我的 prod.log 中,如何禁用它,我只想查看错误。这是我的独白设置:

monolog:
    handlers:
        main:
            type: fingers_crossed
            action_level: error
            handler: file
            excluded_404s:
                - ^/items/
        file:
            type: stream
            level: debug
        doctrine:
            action_level: debug
            type:  stream
            path:  %kernel.logs_dir%/doctrine_%kernel.environment%.log
            channels: doctrine

【问题讨论】:

    标签: php symfony logging monolog


    【解决方案1】:

    您可以定义要记录的频道。使用类似这样的东西来忽略特定的频道:

            channels: ["!security"]
    

    如果您只想忽略特定的日志级别,您可以使用 级别参数或在新处理程序中使用两者的组合。

    【讨论】:

      【解决方案2】:

      在 symfony4 中(可能还有更高的版本) https://symfony.com/doc/current/logging/channels_handlers.html#switching-a-channel-to-a-different-handler

      File: \config\packages\dev\monolog.yaml
      
          monolog:
              handlers:
                  main:
                      type: stream
                      path: "%kernel.logs_dir%/%kernel.environment%.log"
                      level: debug
                      channels: ["!event", "!request", "!security"]
                  # uncomment to get logging in your browser
                  # you may have to allow bigger header sizes in your Web server configuration
                  #firephp:
                  #    type: firephp
                  #    level: info
                  #chromephp:
                  #    type: chromephp
                  #    level: info
                  console:
                      type: console
                      process_psr_3_messages: false
                      channels: ["!event", "!doctrine", "!console", "!request", "!security"]
      

      在我的 symfony4.4 配置(WebServer)中,channels: ["!event", "!doctrine", "!console"] 用于控制台,channels: ["!event"] 用于 Main

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-12-24
        • 2020-01-17
        • 2016-07-04
        • 2023-02-02
        • 2016-07-11
        • 2011-01-08
        相关资源
        最近更新 更多