Reputation: 1359
Let's say my storage/logs directory is empty at the moment. I do a request from Postman and there is an error. So, Laravel attempts to log it to the storage/logs directory. Since it is empty, it creates a new file.
Here it is - please notice the owners/permissions:
-rw-r--r-- 1 www-data www-data 9955 Dec 29 10:29 laravel-2020-12-29.log
I read in this answer that the user should be me (let's call my user myuser
) and that both me and the group should have read and write permissions.
(and I think that's correct - myuser
should be the owner if, for example, I want to run an artisan cmd or sth)
So, I run the following two commands:
sudo chown -R $USER:www-data app/storage
sudo chmod -R ug+w app/storage
Then the permissions of the file become:
-rw-rw-r-- 1 myuser www-data 9955 Dec 29 10:29 laravel-2020-12-29.log
Now, if I try to do a request from Postman again, it still works.
But if I try the next day (or if I delete the file and try again), the new file is created with the initial permissions again:
-rw-r--r-- 1 www-data www-data 9955 Dec 29 10:32 laravel-2020-12-29.log
Why is this happening? What should be done so that the permissions are set to the proper ones?
Upvotes: 3
Views: 698
Reputation: 1934
You can fix this problem with changing the config of your laravel project
Go to this path config/logging.php
and find the line which has daily
as key and change it like this for example:
'daily' => [
...
'permission' => 0664,
],
After that the log file generate with this permission
Upvotes: 3