Ask Your Question
4

How can I make Symfony 3 Console exception logging visible only on the console?

asked 2021-04-07 11:00:00 +0000

david gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2022-02-09 18:00:00 +0000

devzero gravatar image

You can make Symfony 3 Console exception logging visible only on the console by modifying the Monolog configuration.

  1. Open the config.yml file in your Symfony project

  2. Locate the Monolog configuration section. It should look something like this:

    monolog:
       handlers:
           main:
               type: stream
               path: "%kernel.logs_dir%/%kernel.environment%.log"
               level: debug
               channels: [!event]
    
  3. Add a new console handler:

    monolog:
       handlers:
           main:
               type: stream
               path: "%kernel.logs_dir%/%kernel.environment%.log"
               level: debug
               channels: [!event]
           console:
               type: console
               process_psr_3_messages: false
               channels: ["!event", "!doctrine"]
    
  4. Save the file and run the Symfony console commands as usual. The exceptions will now only be visible on the console output.

The process_psr_3_messages option is set to false to prevent console messages from being duplicated in the log file. The channels option tells Monolog which channels to log to the console. In this configuration, we're excluding the event and doctrine channels. Feel free to modify this setting based on your specific needs.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2021-04-07 11:00:00 +0000

Seen: 2 times

Last updated: Feb 09 '22