问题
Heey!
So I've recently been given the task to take a Laravel 5.2 up to 5.6. It seemed to be fine...until I tried to do a \Log::info()
. Every time I run that, I get a big error, but at the end, it still prints to the log. I saw the 5.6 documentation on creating the config/logger.php
. I took a fresh copy of it from github. The only thing I did after that was set an env variable for the LOG_CHANNEL
to be single. Here's the error I get:
[2018-03-02 08:28:59] laravel.EMERGENCY: Unable to create configured logger. Using emergency logger. {"exception":"[object] (InvalidArgumentException(code: 0): Log [] is not defined. at I:\xampp\htdocs\mtm\vendor\laravel\framework\src\Illuminate\Log\LogManager.php:181) [ ....
I did a file comparison between Laravel 5.2 and 5.6. I'm not seeing anything that jumps out that would break the Logging functionality.
Has anyone run into this with a Laravel upgrade?
回答1:
Add this file to your config folder https://github.com/laravel/laravel/blob/develop/config/logging.php
and add this to your .env file LOG_CHANNEL=stack
回答2:
I was facing the same issue due to upgrade of my laravel version from 5.3 to 5.7. But after search of few mints i found the solution. You just need to follow the following steps.
- create logging.php file inside the config folder.
- Copy code from this Official Link of Laravel.
- Past this code into your logging.php file.
- run this command -- php artisan config:clear
All done. Happy Coding :)
回答3:
I recently had the same error in my development machine (and not in the production one, oddly). In my development machine I have both php 7.1
and php 7.2
installed. Checking with phpinfo()
, I discovered that 7.1 was the default version, so I decided to switch to 7.2.
sudo a2dismod php7.1
sudo a2enmod php7.2
sudo systemctl restart apache2
That didn't solve the problem (but maybe was part of it).
After several hours spent on trying everything suggested around the web, I found my solution by:
- Checking all the permissions in the storage folder.
- In my project folder, clearing all the cache(s) and config(s).
- Dumping all composer autoload files.
In detail:
cd your_project_full_path
sudo chmod -R 0775 storage
sudo chown -R www-data:www-data storage
php artisan config:clear
php artisan view:clear
php artisan route:clear
composer dump-autoload
After this, I had no problem any more. Maybe try 0755 as permission for the storage folder. Hope this helps!
回答4:
I got the same problem and tried to do everything as you did but not work.
Finally, I've found that it was because of cached config, just clear it and everything will be fine:
php artisan config:clear
回答5:
After two days of some research, I found a solution on Github.
If you are using Laravel 5.5.4 to Laravel 5.6.*, then you can just install and configure the exceptions package by Graham Campbell.
Link: https://github.com/GrahamCampbell/Laravel-Exceptions
This worked perfectly for me on Mac OSX (PHP 7.1.7), Laravel 5.6.22
My initial error:
2018-05-25 14:35:07] laravel.EMERGENCY: Unable to create configured logger.
Using emergency logger. {"exception":"[object] (InvalidArgumentException(code: 0): Log [] is not defined. at /Users/pro/Sites/metiwave/vendor/laravel/framework/src/Illuminate/Log/LogManager.php:181)
回答6:
use upgrade guide , and add logging.php
to your config files.
来源:https://stackoverflow.com/questions/49073558/laravel-5-6-upgrade-caused-logging-to-break