5

Laravel is automatically clearing the logs on our production server once every seven days. The desired outcome is to keep one log running log file that is never cleared.

I have set 'log_max_files' => 0 in config/app.php. I cleared the cache with php artisan cache:clear, composer dump-autoload, as well as php artisan config:cache.

Our server is running on Google Console and deployed with Laravel Forge. There are no scheduled tasks on forge, nor are there any cronjobs running on the server that would empty the logs (that I know of).

edit: I have verified that the logs are behaving as expected on my development server and are not being emptied. This indicates that it's probably an issue with my production server, possibly Forge configuration or some default behavior on Google Console that might automatically clear logs.

Any advice would be greatly appreciated. Thank you!

  • What's your `log` setting in `config/app.php`? By default, it's set to `'log' => env('APP_LOG', 'single')`, so unless you've overridden it to `daily` or something, it should be behaving as you desire; a single log file that is never emptied. – Tim Lewis Jan 14 '19 at 19:30
  • @TimLewis It's still set to the default `'log' => env('APP_LOG', 'single')`. And there is no `APP_LOG` variable supplied in my `.env` file that would override it. It's a puzzler! – Anthony Head Jan 14 '19 at 19:43
  • Very strange. So you've only got a single `laravel_log` file. How do you know that it's emptied once every 7 days? Also, `log_max_files` doesn't have any effect with `single`; so it could actually be removed if you wanted. – Tim Lewis Jan 14 '19 at 19:44
  • @TimLewis Yes, its the `storage/logs/laravel.log` file. I open it it in vim and hit `gg` in command mode to go to the top of the file. The earliest date stamp at the beginning of the log file I'm assuming is the first log after they were emptied. When I try to search previous dates, they don't exist in the file. And I've been tracking this issue for a while so I know it's exactly seven days when that initial date stamp is reset to a recent one. – Anthony Head Jan 14 '19 at 19:53
  • Yeah, timestamp at the top of the file is the oldest entry in the file. I haven't heard of it emptying on it's own; I have some projects that have massive log files going back _years_. Unfortunately, beyond that, I have no idea... Maybe someone else knows; consider opening an issue on the Laravel git repo (or searching there for a similar issue), or check if maybe your server has some config that could be doing that. – Tim Lewis Jan 14 '19 at 19:57
  • @TimLewis Just thought about this, but I checked the logs on my development server, and they date pretty far back. This would indicate that the app configuration is working as expected, and the logs emptying on the production app is mostly likely (like you said) a server configuration issue -- possibly with Forge. Thanks for taking the time to help! – Anthony Head Jan 14 '19 at 20:03
  • No problem! And yeah, I'd definitely check if there's something on the production server, like an auto-dump based on date, or size (which, with consistent daily logging _could_ be triggered every 7 days by coincidence), etc etc. – Tim Lewis Jan 14 '19 at 20:05

0 Answers0