I have logging enabled by default on Laravel 5.5.
'log' => env('APP_LOG', 'single'),
'log_level' => env('APP_LOG_LEVEL', 'debug'),
Try
php artisan config:cache
If the issue is related to laravel application cache, then the artisan command will help to cache all your config files ( with current changes ) into a single file. In laravel the config values are obtain from the application cache, so you've to run this command whenever you change the config files. To update the application cache with the latest changes.
If the issue is not related to application cache, you can track the real cause using the apache2 error logs.
tail -f /var/log/apache2/error.log
Might be you have given permission and ownership to storage folder not insider folders like: taking case on redhat, because in case of redhat apache user is apache and in case of debian or most other www-data
folder | Permission | ownership
storage | 775 | root:apache
storage/logs | 755 | root:apache
storage/logs | 775 | root:root
It should be minimum
storage/logs | 775 | root:apache
or
storage/logs | 755 | apache:apache
and please check once with APP_DEBUG=true
May you have accidentally changed default log path or anything in the configuration array
'single' => [
'driver' => 'single',
'path' => storage_path('logs/laravel.log'),
'level' => 'debug',
],
Ensure that your log level is set to debug, and remember to clear your config cache after changing that value
.env file
APP_LOG_LEVEL=debug
run in console
php artisan config:cache
So two things here:
.env
file, basically checking to see if it's not a falsey value.:APP_LOG=daily
storage
directory is writable to the server user:chmod -R 755 storage
change the file permission to 777 and if the errors exist in log file it is for permission . you can check the user run php using :
ps aux | egrep '(apache|httpd)'
and correct the file permission .
if the problem is not for permission then you can use error_get_last() after the code lines you write in the log file and see what is the error.
if you don't have error maybe the address of write log file in config is incorrect
I found the issue. I am using Bugsnag (for production) and I had set it up in the project.
When I integrated it, I used the instruction it had on its dashboard, which I believe was not complete as they have it on theirdocumentation . So, I had added the following code in the register method of my application service provider app/Providers/AppServiceProvider.php.
$this->app->alias('bugsnag.logger', \Illuminate\Contracts\Logging\Log::class);
$this->app->alias('bugsnag.logger', \Psr\Log\LoggerInterface::class);
In my local environment, I had not set the BUGSNAG_API_KEY
in my .env
file. So, it was neither sending the exceptions to Bugsnag nor logging into the local laravel.log file.
When I was integrating Bugsnag to another project which runs on Laravel 6, I suspected this issue and checked the documentation. There I found the code which is needed to keep logging to my original logger as well as Bugsnag.
$this->app->alias('bugsnag.multi', \Illuminate\Contracts\Logging\Log::class);
$this->app->alias('bugsnag.multi', \Psr\Log\LoggerInterface::class);
if you're experiencing this after logging was ok, then its easy to fix. At first do so, in terminal:
echo "" > storage/logs/laravel.log
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.