Today, i will let you know example of create custom log file in laravel. This article will give you simple example of how to make custom log file laravel. This article will give you simple example of laravel custom log file name. i explained simply about how to create custom log file in laravel. You just need to some step to done laravel custom log file example.
Laravel by default provide storage/logs/laravel.log file location where it will display log file. but sometime you may require to create log file with specific task. for example, if you are working with payment task and you need all logs separately log file for payment, so you can easily find out solution.
here, i will give you very simple example, so let's see how to add custom channel with new log file location. add new key "itsolution" on "channels" array.
config/logging.php
...
'channels' => [
...
'itsolution' => [
'driver' => 'single',
'path' => storage_path('logs/itsolution.log'),
'level' => 'info',
],
....
Route Code:
Route::get('create-custom-log', function () {
\Log::channel('itsolution')->info('This is testing for HDTuto.com!');
dd('done');
});
now you can check your own.
storage/logs/itsolution.log
[2021-04-13 11:46:41] local.INFO: This is testing for HDTuto.com!
I hope it can help you...
Do you like below Tutorials ?
- How to Display Data in Angular 10?
- Angular 10 Routing Module Example Tutorial
- Angular 10 CRUD Operations with Web API Example
- Laravel 8 CRUD Operation Step By Step Tutorial
- Solved - Target class [ProductController] does not exist in Laravel 8
- Step by Step Form Validation in Laravel 8 Example
- Laravel 8 Image Upload with Preview Example
- Laravel 8 Multiple Images Upload with Preview Example