You are browsing the documentation for Symfony 3.3 which is not maintained anymore.
Consider upgrading your projects to Symfony 5.2.
How to Enable Logging in Console Commands
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.