How to Enable Logging in Console Commands

Version: 3.3
Edit this page

Warning: You are browsing the documentation for version 3.3 which is not maintained anymore.

If some of your projects are still using this version, consider upgrading.

How to Enable Logging in Console Commands

In Symfony versions prior to 3.3, the Console component didn't provide any logging capabilities out of the box and you had to implement your own exception listener for the console.

Starting from Symfony 3.3, the Console component provides automatic error and exception logging.

You can of course also access and use the logger service to log messages.

This work, including the code samples, is licensed under a Creative Commons BY-SA 3.0 license.