'A problem with automatically increasing the file size in a project laravel

I have a problem with a file named storage\logs\laravel.log From LARAVEL Project Files The strange thing is that this file is automatically increased in size every day, so I needed to delete it so that the site would not stop working Do you have a solution to this problem how to stop this file from working automatically So that the site does not stop because there is no free space



Solution 1:[1]

You can change logging driver to daily. This will create new log file daily, with date in file name.

in config/logging.php

'default' => env('LOG_CHANNEL', 'daily'),

'channels' => [
    ....

    'daily' => [
        'driver' => 'daily',
        'path' => storage_path('logs/laravel.log'),
        'level' => env('LOG_LEVEL', 'debug'),
        'days' => 14,
    ],
    ....

Set the number days that you want log files to keep. After that the old log files will be deleted automatically.

For more information Check the Laravel documentation for Logging.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 N69S