How to clear the Laravel.log file in Laravel?
In this tutorial, we will learn How to clear the Laravel.log file in Laravel. Laravel logging is based on “channels”. every channel represents a specific way of writing log information. For example, a single channel writes log files to a laravel.log file and the daily channel writes log files to a daily laravel.log file, while the slack channel sends log messages to slack. The Laravel.log file contains logs from various actions. The Laravel.log file is usually located in project>/storage/logs/
.
#laravel.log
[2022-04-14 14:56:06] local.INFO: This is some useful information.
[2022-04-14 14:56:06] local.WARNING: Something could be going wrong.
[2022-04-14 14:56:06] local.ERROR: Something is really going wrong.
We use the below methods easily to clear the laravel.log file.
Linux command
Open a terminal and run the below command.
truncate -s 0 storage/logs/laravel.log
Windows command
Open cmd(Command prompt) and run the below command.
echo "" > storage/logs/laravel.log
If you check this example and have no log data. you can create the below code to log.
Route::get('/', function () {
//return view('welcome');
Log::info('This is some useful information.');
Log::warning('Something could be going wrong.');
Log::error('Something is really going wrong.');
});