Before utilizing our custom log file, we must first add the new Log Channel to the configuration.
To do this, follow these steps:
Open the `config/logging.php` file and add the following under the 'channels' array:
'channels' => [
'my_custom_log' => [
'driver' => 'single',
'path' => storage_path('logs/my_custom.log'),
'level' => env('LOG_LEVEL', 'debug'),
'replace_placeholders' => true,
],
//....
You can customize the 'my_custom_log' channel name and 'my_custom.log' log file name to suit your requirements.
To log to the new channel, use the following:
\Log::channel('my_custom_log')->info('Test Log');
All your logs will be saved to the configured file.