Log errors can be really useful when your website is online to not show errors to the client or to simply log when you develop a theme or plugin.
Parvula suggest Seldaek/Monolog to log what you want.
- Firstly install Monolog
composer require monolog/monolog
- If you want to log error and exception, enable the log
logErrors: truein system.yaml
- It is recommended to disable the debug because Whoops block the current exception and throw a new exception.
debug: truein system.yaml
To log what you want, use the service registered as ‘logger’ in the router (
A basic example could be: