Laravel - Errors and logging

Laravel - Errors and logging

This will covers errors and logging in Laravel projects and how to resolve them.

mistakes

The project in the process of implementation carries several errors. Error and exception handling is already set up for you when starting a new Laravel project. Usually in a local environment, we should see errors for debugging purposes. We need to hide these errors from users in a production environment. This can be achieved with the APP_DEBUG variable set in the .env environment file stored at the root of the application.

For local environments, APP_DEBUG should be true, but for production it should be set to false to hide errors.

Note. After changing the APP_DEBUG variable, you need to restart the Laravel server.

logging

Logging is an important mechanism by which a system can log generated errors. This is useful for improving system reliability. Laravel supports various logging modes such as single, daily, syslog, and error log modes. You can set these modes in the config/app.php file .

'log' => 'daily'You can see the generated log entries in storage/logs/laravel.log file