February 2, 2017 Javier Eguiluz

The Console component doesn't provide any logging capabilities out of the box because you normally run console commands yourself and observe the output. However, there are cases when you might need logging; for example, when running console commands unattended, such as from Cron jobs or deployment scripts.

In Symfony 3.2 you had to create your own event listener or subscriber to subscribe to the console.exception event and log the exception details. In Symfony 3.3 we decided to enable automatic exception logging for console commands.

Therefore, when an exception occurs during the execution of a command, you'll see a message like the following in your log file:

1 2 3 4 5 [2017-02-15 09:34:42] app.ERROR: Exception thrown while running command: "cache:clear -vvv". Message: "An error occured!" {"exception":"[object] (RuntimeException(code: 0): An error occured! at vendor/symfony/symfony/ src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php:61)", "command":"cache:clear -vvv","message":"An error occured!"} []