In laravel, you can use the truncate command to delete the log. This command is used to clear the specified data. Use this command to clear the contents of the "laravel.log" file. The syntax is "truncate -s 0 storage/logs /laravel.log".
#The operating environment of this article: Windows 10 system, Laravel version 6, Dell G3 computer.
1. How to delete (clear) the laravel.log file in Laravel
Sometimes phpstorm cannot open this file because it is too big
The laravel.log file cannot be cleared manually. For example, opening the file and selecting delete will have no effect.
There is a simple command to clear the laravel.log file
Enter this command at the command line
truncate -s 0 storage/logs/laravel.log
2. Custom log
For example, I have a text message log that I need to write, but I don’t want to write it to laravel.log. What to do? It’s very simple. Just add a driver directly to config/logging.php
'sms' => [ 'driver' => 'daily',//单个文件还是按天 'path' => storage_path('logs/sms.log'),//存储文件 'level' => 'info',//日志级别 'days' => 14,//时间周期 ],
Call:
Log::channel('sms')->info('短信内容')
[Related recommendations: laravel video tutorial]
The above is the detailed content of How to delete logs in laravel. For more information, please follow other related articles on the PHP Chinese website!