symfonysymfony4monologdeprecation-warning

How to exclude deprecation messages from logs in Symfony 4?


I have migrated an application from Symfony 3.4 to Symfony 4.4.

Now I have a lot of deprecations for each request/ Sf command (I can't fix that deprecations).

How can I exclude deprecations from the log for this Symfony App?


Solution

  • Exclude the php channel from the log handler:

    Eg. config/packages/prod/monolog.yaml:

    monolog:
        handlers:
            main:
                type:  stream
                path:  %kernel.logs_dir%/%kernel.environment%.log
                level: debug
                formatter: monolog.formatter.session_request
                channels:
                 -  '!php' # <----------- add this line
    

    Leave deprecation messages in the dev mode though. You should be aware of the changes in upstream packages.

    PS. in newer Symfony versions you have to exclude the deprecation channel instead, i.e.:

    channels:
        - '!deprecation'