Reputation: 21
I've changed my app.php
configuration to use daily error logs and to only keep 7 of them:
/*
|--------------------------------------------------------------------------
| Logging Configuration
|--------------------------------------------------------------------------
|
| Here you may configure the log settings for your application. Out of
| the box, Laravel uses the Monolog PHP logging library. This gives
| you a variety of powerful log handlers / formatters to utilize.
|
| Available Settings: "single", "daily", "syslog", "errorlog"
|
*/
'log' => env('APP_LOG', 'daily'),
'log_max_files' => 7,
However, nothing is being written in these log files because they can't be written in, according to apache's error log:
PHP Fatal error: Uncaught exception 'UnexpectedValueException' with message 'The stream or file "/var/www/newshub/storage/logs/laravel-2016-07-18.log" could not be opened: failed to open stream: Permission denied'
I tried recursively changing write permissions for both the storage
and logs
directories. This worked, but when the next day's error log was created, it no longer had write permissions.
How can I fix this?
Upvotes: 0
Views: 2164
Reputation: 1550
Change the owner with ubuntu or apache based on your OS to storage folder recursively. It will work without any further issues.
example: sudo chown -R apache:apache /var/www/html/storage (based on your current location of storage)
Upvotes: 0
Reputation: 364
cd /var/www/newshub/storage/
chmod -R 0777 logs
try these commands with ssh please
Upvotes: -1
Reputation: 298
I had exactly the same issue. Each day the file creates and then I am not able to write to that. The problem was with the owner of the file. This should be www-data but it gets created by another user. I run the command
sudo chown -R ubuntu:www-data /storage
and everything works fine.
To solve this problem, I created a crontab to run every day to change the ownership of the newly created file. This was run immediately after the file was generated for that day. This is a short-term fix, but researching on how to get this fixed long term.
Upvotes: 1
Reputation: 2475
Are you using GIT to update the codebase on your server?
I have noticed that sometimes when I pull, permissions for some directories are lost, never happened with logs
directory but worth a look.
As for Laravel goes, this isn't exactly on the framework rather than a server configuration issue.
Upvotes: 0