In this example, we will show laravel create a custom log file example. In this post, you will learn how to create a custom log file in laravel. I explain a simple example of the laravel custom log file example. Follow bellow example step of how to make a custom log file laravel.


Laravel by default provides storage/logs/laravel.log file location where it will display a log file. but sometimes you may need to create a log file with a specific task. for example, if you are working with a payment task and you need all logs separately log file for payment, so you can easily find out the solution.


let’s see how to add a custom channel with a new log file location.

config/logging.php
...
'channels' => [
        ...
        'webtuts' => [
            'driver' => 'single',
            'path' => storage_path('logs/rathorji.log'),
            'level' => 'info',
        ],
....


Create Route 

Route::get('create-custom-log', function () {
  
    \Log::channel('rathorji')->info('This is testing');
    dd('done');
     
});


Now you can check your own application path such as : storage/logs/rathorji.log



I hope you understand of laravel custom log file example and it can help you…