In my applicaiton, I use laravel.log file that are created daily at 00:00 UTC. However, sometimes the file gets created with root:root user/group instead of usual webapp:webapp (apache user). This crashes my application because the application can no longer write to it. I noticed that the file ownership may be changing after the file has been written for a while (couple of minutes).
- What could have potentially caused the ownership of the file to change after it is created?
- Is there a way in Laravel to try/catch logging so that the application doesn't crash due to file write errors?
Permission on the storage directory and files is not an issue because it has been working fine for a long time. It is only the laravel.log file's ownership changing occasionally without intervention.