4

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?

1
  • You mean you want to disable the access log? Commented Mar 5, 2014 at 14:29

1 Answer 1

5

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

Sign up to request clarification or add additional context in comments.

2 Comments

Is there a problem with indentation in this answer? The first 2 lines are at the same level.
Al : Yes it need 4 spaces before "handlers" keyword. I ll edit answer

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.