简体   繁体   English

如何在 monolog symfony2 日志记录中禁用 security.info 和 security.debug

[英]how to disable security.info and security.debug in monolog symfony2 logging

I constantly am seeing a bunch of the following log:我经常看到一堆以下日志:

[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 [] []

in my prod.log, how can I disable this and I just want to see the errors.在我的 prod.log 中,如何禁用它,我只想查看错误。 Here is my monolog settings:这是我的独白设置:

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

You can define which channels to be logged.您可以定义要记录的频道。 Use something like this to ignore a specific channel:使用这样的东西来忽略一个特定的频道:

        channels: ["!security"]

If you only want to ignore specific log levels you can use the level param or use a combination of both in a new handler.如果您只想忽略特定的日志级别,您可以使用级别参数或在新处理程序中使用两者的组合。

In symfony4(And maybe higher versions) https://symfony.com/doc/current/logging/channels_handlers.html#switching-a-channel-to-a-different-handler在 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"]

In my config (WebServer) of symfony4.4 I had channels: ["!event", "!doctrine", "!console"] for Console and channels: ["!event"] for Main在我的 symfony4.4 配置(WebServer)中,我有channels: ["!event", "!doctrine", "!console"]用于控制台和channels: ["!event"]用于 Main

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM