Tejas Gosai
Tejas Gosai

Reputation: 362

Disable log in Symfony2

This question may have been asked before. I have searched for answers, but I haven't found what I was looking for.

In Symfony 2.3, is there a way to disable the logger for specific requests? I mean, I am using a SOAP service for my project. When I send a request to login, the username and password are dumped straight as plain text into the log file. Is there a way to stop logging this kind of specific requests?

For example, when I send a request for login, the logger should be disabled, but for all other request it works again. Is this possible?

Upvotes: 4

Views: 12355

Answers (1)

Charles-Antoine Fournel
Charles-Antoine Fournel

Reputation: 1783

depending if your are in Prod or Dev environement but everything is in config.yml or config_dev.yml :

to disable logging just remove monolog configuration like this :

monolog:
  handlers:
    main:
        type:   stream
        path:   "%kernel.logs_dir%/%kernel.environment%.log"
        level:  debug
    console:
        type:   console
        bubble: false
    # 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

but in my opinion , you shouln't do this because logging allows you to improve significantly your code !

Logging except for a specific service :

You need to create a specific log channel for your service as described there : http://symfony.com/doc/current/cookbook/logging/channels_handlers.html and there : http://symfony.com/doc/current/reference/dic_tags.html#dic-tags-monolog

you ll be able to separate your soap log from others and eventually send it to null

Upvotes: 5

Related Questions