how to set Log rotate in laravel?

Viewed 836

Right now I'm using a single log file, but there is requirement to make it daily , but for the current date, the file name must be laravel.log

laravel-2020-08-30.log
laravel-2020-08-31.log
laravel-202-009-01.log  -> the current date must be laravel.log

`

Is it possible to get the logs daily, but named like this?

laravel.log

While the older (up to a week) are named like this:

laravel-2020-08-30.log

1 Answers

You can try given solution for you problem.

Update your .env file.

LOG_CHANNEL=daily

then you can run following this command on your terminal inside project root directory.

php artisan config:clear && php artisan cache:clear && php artisan config:cache

Now you can check your storage folder inside logs directory with following name conversion.

For ex: laravel-2020-09-01.log

Related