[Laravel] log 파일 주기적으로 삭제하기
2022. 11. 15. 13:10ㆍLaravel
routes/console.php 파일 아래와 같이 수정
<?php
use Illuminate\Foundation\Inspiring;
use Illuminate\Support\Facades\Artisan;
/*
|--------------------------------------------------------------------------
| Console Routes
|--------------------------------------------------------------------------
|
| This file is where you may define all of your Closure based console
| commands. Each Closure is bound to a command instance allowing a
| simple approach to interacting with each command's IO methods.
|
*/
Artisan::command('inspire', function () {
$this->comment(Inspiring::quote());
})->purpose('Display an inspiring quote');
<?php
use Illuminate\Foundation\Inspiring;
use Illuminate\Support\Facades\Artisan;
/*
|--------------------------------------------------------------------------
| Console Routes
|--------------------------------------------------------------------------
|
| This file is where you may define all of your Closure based console
| commands. Each Closure is bound to a command instance allowing a
| simple approach to interacting with each command's IO methods.
|
*/
// Artisan::command('inspire', function () {
// $this->comment(Inspiring::quote());
// })->purpose('Display an inspiring quote');
Artisan::command('logs:clear', function() {
exec('rm -f ' . storage_path('logs/*.log'));
exec('rm -f ' . base_path('*.log'));
$this->comment('Logs have been cleared!');
})->describe('Clear log files');
php artisan logs:clear
커맨드를 직접 입력하거나 서버 crontab에 일정 주기를 설정해서 로그파일을 날리는 방법이 있다.
'Laravel' 카테고리의 다른 글
[Laravel] Gmail SMTP 설정 (0) | 2022.11.15 |
---|---|
[Laravel] Syntax error or access violation: 1055 에러 (0) | 2022.02.07 |
[laravel] 데이터베이스 시딩 (0) | 2022.01.17 |
[laravel] sanctum (API 인증) 구축 (0) | 2022.01.04 |
[laravel] application Key 생성 (0) | 2022.01.04 |