Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 534
FreezeBee Avatar asked Dec 27 '19 13:12

FreezeBee


2 Answers

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.

like image 79
emix Avatar answered Nov 07 '22 07:11

emix


Set the following env variable (eg. in .env.local):

SYMFONY_DEPRECATIONS_HELPER=weak
like image 1
Micronax Avatar answered Nov 07 '22 09:11

Micronax