How can I define the maximum number of log files in Laravel 5. I use daily log rotate, and I have "only" 5 log files in storage, I want to have the past 30 days, but I don't know how to do this, and I did not found any clue.
如何在Laravel 5中定义日志文件的最大数量。我使用每日日志旋转,并且我在存储中“只有”5个日志文件,我想要过去30天,但我不知道该怎么做这个,我没有发现任何线索。
3 个解决方案
#1
24
Ok, it's now possible since v5.0.23. You just need to update laravel, and add this in your config/app.php
file:
好的,现在可以从v5.0.23开始。您只需要更新laravel,并在config / app.php文件中添加:
'log_max_files' => 30
#2
4
On Laravel 5.6 open file config/logging.php
on array daily change: 'days' => 30
在Laravel 5.6上打开文件config / logging.php在数组每日更改:'days'=> 30
If you want unlimited logs just put 0 instead 30.
如果你想要无限制的日志,只需输入0而不是30。
#3
3
There is a function in ConfigureLogging
or LogServiceProvider
or so (Since I'm using an old checkout I'm not sure where exactly), something called useDailyFiles
. In that the file name and maximum file number is set and the default looks something like this:
在ConfigureLogging或LogServiceProvider中有一个函数左右(因为我使用旧的签出,我不确定在哪里),称为useDailyFiles。因为文件名和最大文件号已设置,默认值如下所示:
$log->useDailyFiles(storage_path().'/logs/laravel.log', 5);
Change the last parameter (5) to your desired number of files.
将最后一个参数(5)更改为所需的文件数。
#1
24
Ok, it's now possible since v5.0.23. You just need to update laravel, and add this in your config/app.php
file:
好的,现在可以从v5.0.23开始。您只需要更新laravel,并在config / app.php文件中添加:
'log_max_files' => 30
#2
4
On Laravel 5.6 open file config/logging.php
on array daily change: 'days' => 30
在Laravel 5.6上打开文件config / logging.php在数组每日更改:'days'=> 30
If you want unlimited logs just put 0 instead 30.
如果你想要无限制的日志,只需输入0而不是30。
#3
3
There is a function in ConfigureLogging
or LogServiceProvider
or so (Since I'm using an old checkout I'm not sure where exactly), something called useDailyFiles
. In that the file name and maximum file number is set and the default looks something like this:
在ConfigureLogging或LogServiceProvider中有一个函数左右(因为我使用旧的签出,我不确定在哪里),称为useDailyFiles。因为文件名和最大文件号已设置,默认值如下所示:
$log->useDailyFiles(storage_path().'/logs/laravel.log', 5);
Change the last parameter (5) to your desired number of files.
将最后一个参数(5)更改为所需的文件数。