In Laravel framework, they store all error store in logs file and they keep in storage folder. Logs will help to find where is error and why in details. Because in every exception it put automatically in log file. You can also put manually log like as bellow few examples:
Log::info('Info Log');
Log::alert('Alert Log');
Log::error('Error Log');
As above and there are others also available and it store on default file path "storage/logs/laravel.log"
But sometime we need to change file location or need to create our custom log for specific logs like info.log, alert.log, error.log etc then how is it possible.
As specially i required to create my custom log file during my project work and i fond way to create custom log file by using useDailyFiles() OR useFiles(). I gave you example bellow and also output.
Using useDailyFiles()
Path: storage/logs/mycustom-2017-07-07.log(current date)
Log::useDailyFiles(storage_path().'/logs/mycustom.log');
Log::info('my test log');
Using useFiles()
Path: storage/logs/mycustom.log
Log::useFiles(storage_path().'/logs/mycustom.log');
Log::info('my test log');
You can use any one. I hope you fond your best solution....
Do you like below Tutorials ?
- Laravel - chmod(storage/oauth-private.key): Operation failed: Operation not permitted
- Laravel 7.x and 6.x datatables example from scratch
- How to compress PNG image using pngquant in PHP?
- Laravel 7.x and 6.x Chart example using Charts Package
- Guzzle http client GET and POST request example in Laravel 5
- Laravel schema default current timestamp value example
- Laravel 7.x and 6.x Get Site URL Examples
- Convert object to array in laravel 7.x and 6.x example