2

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

ezles88
  • 159
  • 1
  • 12
  • Laravel is provide formate like `FILE_PER_DAY (Y-m-d), FILE_PER_MONTH (Y-m), FILE_PER_YEAR (Y)`. You can set one of the date formats using slashes, underscores and/or dots instead of dashes. let me know what actual you have required. – NikuNj Rathod Sep 01 '20 at 05:04
  • i want the log create daily, the current date log file will be laravel.log and the previous date separate based on the date ig laravel-2020-01-01.log – ezles88 Sep 01 '20 at 05:52
  • You want the Log file name like `laravel-2020-01-01.log`. right? – NikuNj Rathod Sep 01 '20 at 05:58
  • yes for the previous date, but for the current date only laravel.log without yyyy-mm-dd – ezles88 Sep 01 '20 at 06:03

1 Answers1

3

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

NikuNj Rathod
  • 1,663
  • 1
  • 17
  • 26
  • why `cache:clear` ... why do people keep telling people to clear their "cache store" ... and you don't need to clear the config to just cache it, you can just cache it `config:cache`, but if you are developing locally, there is no reason to ever cache your config or routes – lagbox Sep 01 '20 at 06:37
  • @lagbox Yes, I am agree with you but some It will be get all configuration values so that It will be batter to clear cache. – NikuNj Rathod Sep 01 '20 at 06:41