diff --git a/console/logging.rst b/console/logging.rst index 000165112b0..bba568798f2 100644 --- a/console/logging.rst +++ b/console/logging.rst @@ -11,5 +11,22 @@ listener for the console. Starting from Symfony 3.3, the Console component provides automatic error and exception logging. +When an exception occurs during the execution of a command, you'll see a message +like the following in your log file: + +.. code-block:: terminal + + [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!"} [] + +In addition to logging exceptions, the new subscriber also listens to the +`console.terminate` event to add a log message whenever a command +doesn't finish with the 0 exit status. + + + You can of course also access and use the :doc:`logger ` service to log messages.