Skip to content
Advertisement

Saving command logger output to log file and console

I wrote a very simple test command which has LoggerInterface injected in its constructor.

How am I suppose to change the monolog.yaml configuration to save this logger output to both log file and to output it to console?

JavaScript

Advertisement

Answer

The commands will always stderr by default (if you specify the -vvv option)

If you need to write the logs in a file only on error (with the stack error) you can use the finger_crossed handler :

JavaScript

If you want to filter a bit the logs shown in the stderr you can use the default config for the console :

JavaScript

I’ll allow you to have nicer console logs (and avoid too many “useless” logs such as event or doctrine which are very verbose)

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement