# How to Create Custom Log File in Laravel? (ok)

C:\xampp\htdocs\reset\routes\web.php

```
<?php
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
 */
use App\Http\Controllers\HomeController;
Route::get('/', function () {
  dd('Welcome to simple user route file.');
});
Auth::routes();
Route::get('/home', [App\Http\Controllers\HomeController::class, 'index'])->name('home');
Route::get('create-custom-log', function () {
    \Log::channel('itsolution')->info('This is testing for ItSolutionStuff.com!');
    dd('done');
});
```

C:\xampp\htdocs\reset\config\logging.php

```
'channels' => [
    'itsolution' => [
        'driver' => 'single',
        'path' => storage_path('logs/itsolution.log'),
        'level' => env('LOG_LEVEL', 'info'),
    ],
```

C:\xampp\htdocs\reset\storage\logs\itsolution.log

```
[2022-05-13 07:29:37] local.INFO: This is testing for ItSolutionStuff.com!  
[2022-05-13 07:31:27] local.INFO: This is testing for ItSolutionStuff.com!  
```

## How to Create Custom Log File in Laravel?

By Hardik Savani April 14, 2021 Category : Laravel![](https://a.vdo.ai/core/assets/img/cross.svg)PlayUnmuteLoaded: 1.01%Fullscreen[![VDO.AI](https://a.vdo.ai/core/assets/img/logo.svg)](https://vdo.ai/?utm_medium=video\&utm_term=itsolutionstuff.com\&utm_source=vdoai_logo)This example is focused on laravel custom log file name. This article goes in detailed on how to create custom log file in laravel. This article will give you simple example of laravel custom log file example. it's simple example of create custom log file in laravel. Follow bellow tutorial step of how to make custom log file laravel 6, laravel 7, laravel 8 and laravel 9 version.

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 ItSolutionStuff.com!');    dd('done');     });
```

now you can check your own.

**storage/logs/itsolution.log**

Read Also: [Laravel Migration Custom Index Name Example](https://www.itsolutionstuff.com/post/laravel-migration-custom-index-name-exampleexample.html)

```
[2021-04-13 11:46:41] local.INFO: This is testing for ItSolutionStuff.com!  
```

I hope it can help you...


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://learnphp.gitbook.io/learnphp/laravel-advanced/how-to-create-custom-log-file-in-laravel-ok.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
