Tutorialsplane

Laravel Errors And Log


Laravel Errors And Log – Laravel provides the some default error and logging system when we start a new project. In addition laravel also provides you monolog library which enables provides various powerful log handlers. Here in this tutorial we are going to cover the laravel error logging system with various example.


Laravel Errors And Log | Create Custom Log File Example

Configuration

Laravel Monolog Configuration-

You can configura Monolog configuration in config/app.php Add the monolog configuration before returning the $app variable.

Laravel Enable Error Logging –

To Enable the error log add the below settings in the config/app.php file-

Laravel enable debug mode Configuration

//'debug' => env('APP_DEBUG', false) Default 
'debug' => env('APP_DEBUG', true)

Laravel Create Custom Logs –

You can crate Custom log in Laravel Simply as Below –

Laravel Create Custom Log File:

<?php class TestController extends Controller
{
    
    public function editProfile($id)
    {
        Log::info('Editing profile. Userid = '.$id);
		// Other stuffs Here..
    }
}

??>

The above example will create a log with the information provided.

Here are the following logging levels available-

Laravel General

pagination

Laravel More