I am developing a laravel application. I am facing the laravel daily log file problem. I updated 'channels' => ['daily'] instead of 'channels' => ['single'] in the channels an array of config/logging.php file. When I login in application's live server, the new date laravel log file can not open automatically. So I am always setting this command "sudo chmod -R 777 /var/www/html/storage/logs" when I login in live server. Why can not access the new date log file automatically? Could you please help me? Thanks.
Related
Please excuse me, as there are already many questions on the same topic.
First some background: I started working on a Laravel 9 web application few months ago, created AWS S3 buckets and an IAM user with full access to AmazonS3, and used the user's access credentials in .env file. And I was able to upload files to the specified bucket, and was able to access the uploaded files in my web application.
Last week, I worked on SMTP setup for sending emails and made some changes to the .env file (though I am sure that I did not change the AWS settings). Now I notice that the uploading files to the AWS S3 bucket is failing with the message:
exception: "League\\Flysystem\\UnableToWriteFile"
file:"/var/www/vhosts/silkweb.ca/vendor/league/flysystem/src/UnableToWriteFile.php"
line: 24
message: "Unable to write file at location: user/profile/3/P2jFdBHTE49mxym6jxa4LHTAPvV0qDiFZ9SsYtZt.png. Error executing \"PutObject\"
I use the following commands to put the file in the AWS S3 bucket:
$filepath = "/user/profile/".$user_id;
$upload_path = Storage::disk('s3')->put($filepath, $request->file('file'));
I even created a new IAM user and used that user's credentials in my .env file, but still no luck. My current .env settings for AWS are as follows
AWS_ACCESS_KEY_ID=AKI***************DAY
AWS_SECRET_ACCESS_KEY=jotz*************************ru
AWS_DEFAULT_REGION=us-east-2
AWS_BUCKET=silkweb
AWS_URL=silkweb.s3.us-east-2.amazonaws.com
AWS_ENDPOINT=http://silkweb-s3.us-east-2.amazonaws.com
AWS_USE_PATH_STYLE_ENDPOINT=false
I have used php artisan clear:cache and php artisan config:clear several times.
Any idea, why I am not able to create a file in the AWS S3 bucket?
After I commented the AWS_URL and AWS_ENDPOINT, file upload started working. The following are the working settings
AWS_ACCESS_KEY_ID=AKI***********DG
AWS_SECRET_ACCESS_KEY=l36***************0C
AWS_DEFAULT_REGION=us-east-2
AWS_BUCKET=silkweb
AWS_USE_PATH_STYLE_ENDPOINT=false
AWS_S3_SILKWEB_URL="https://silkweb.s3.us-east-2.amazonaws.com/"
**#AWS_URL=silkweb.s3.us-east-2.amazonaws.com**
**#AWS_ENDPOINT=http://silkweb-s3.us-east-2.amazonaws.com**
I have a Laravel 8 Project on my Local Windows PC. I uploaded the project to my shared web hosting on Dreamhost via zip file and copying the entire database to remote host. (I am unable to use Composer and php artisan commands on the remote server) I am using Spatie Roles & Permissions in my project.
Later I had to add a new permission 'holiday_vacation' in my project. I created the new permission using artisan commands on my local system I believe that when a new permission is created, it adds a new record in the permissions table and a when a user is given access to a specific permission, a record is added to the model_has_permissions table. I believe that no other table is changed during this process. The newly created 'holiday_vacation' permission works fine on my local system.
However, after I manually updated the remote tables (permissions and model_has_permissions), the remote system is unable to find the new permission (holiday_vacation). The following commands in a controller display error message, "There is no permission named holiday_vacation for guard web."
if(auth()->user()->hasPermissionTo('holiday_vacation') )
{
dd("Has access");
}
I am absolutely sure that the permissions table has the holiday_vacation permission as I copied the permissions and model_has_permissions tables from the local database to the remote one.
Google search on this issue talks about clearing permission cache (e.g. php artisan cache:forget spatie.permission.cache then php artisan cache:clear). Unfortunately, I can't execute php artisan commands on my shared hosting.
Can someone offer a workaround, please?
#BABAK ASHRAFI's comment did the trick, except that the command needed to be modified slightly. (Ref: https://spatie.be/docs/laravel-permission/v3/advanced-usage/cache)
app()->make(\Spatie\Permission\PermissionRegistrar::class)->forgetCachedPermissions();
My Joomla is 3.9.4, when I try to make some global configuration change on back-end, I got this error: Could not write to the configuration file.
I looked at the file system, configuration.php has the right owner and is set to 0644, actually I can make change to it via FTP.
I then try settiong the permission to 0777, it is writable; then I try 0666 and 0664, it is also good. Only when I set it to 0644, I get the above error. I've never encountered this kind of problem before. What could possibly be wrong?
I think you have to check PHP Ownership. PHP code can be executed not using the same user ID like using FTP. You can set your web server to run PHP as CGI to ensures that PHP is executed using the same user.
I am using 5.1 version of Laravel with PHP 5.6. From Laravel website, I gather that it will be possible to log to syslog via their monolog library. But I can't find any examples on how to do that. Can you please tell me how to log to syslog from Laravel? I tried setting the APP_LOG=syslog in .env file. That causes Laravel to stop logging to file but it does not log anything to syslog. How do I specify syslog server ip:port or socket address?
According to the documentation, you should use this in config/app.php:
'log' => 'syslog'
Log Modes
Out of the box, Laravel supports single, daily, syslog and errorlog
logging modes. For example, if you wish to use daily log files instead
of a single file, you should simply set the log value in your
config/app.php configuration file.
It says in the docs to set the log value in your config file config/app.php to syslog:
'log' => 'syslog'
https://laravel.com/docs/5.1/errors#configuration
I have an application developed on Yii Framework and it was fully working on Ubuntu 11.04 on Linux. I recently had to move it to Mac Os. At the moment is mostly working but the logging function is not. It is not writing on /protected/runtime/application.log. I granted the right permissions to the /runtime folder, but still the error messages are not being logged in application.log.
First, I'd double-check that you've configured the logger to log at the appropriate level (e.g. is trace logging enabled?).
Once I did that and confirmed that my settings were correct but logging was still not happening I would then double-check the directory permissions and ownership for protected/runtime. It's terrible practice but you could just set runtime/ to 777 to ensure that it's globally writable. If chmodding it to 777 works then it's a permissions thing and you'll need to sort those out by ensuring that the web server (usually _www/_www on OSX) can write to the directory and that you can read the directory and the files therein.
The way I handle this on localhost is I just add my user to the _www group and chgrp -R _www then chmod g+rwx my Yii directory. This allows both me and apache to have all access.
have you cinfigured logging to file in your main.php:
'components' => array(
'log' => array(
'class' => 'CLogRouter',
'routes'=>array(
array(
'class'=>'CFileLogRoute',
'levels'=>'error, warning, info',
),
),