Laravel 5.6 升级导致 Logging 中断
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/49073558/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Laravel 5.6 Upgrade caused Logging to break
提问by cbloss793
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:
所以我最近接到了将 Laravel 5.2 升级到 5.6 的任务。这似乎很好......直到我尝试做一个\Log::info()
. 每次我运行它时,都会出现一个大错误,但最后,它仍然会打印到日志中。我看到了有关创建config/logger.php
. 我从 github 上拿了一份新的副本。在那之后我做的唯一一件事就是设置一个环境变量,LOG_CHANNEL
使其成为单身。这是我得到的错误:
[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) [ ....
[2018-03-02 08:28:59] laravel.EMERGENCY:无法创建配置的记录器。使用紧急记录器。{"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.
我在 Laravel 5.2 和 5.6 之间做了一个文件比较。我没有看到任何会破坏日志记录功能的跳出内容。
Has anyone run into this with a Laravel upgrade?
有没有人在 Laravel 升级时遇到过这个问题?
回答by MohamedBenhida
Add this file to your config folder https://github.com/laravel/laravel/blob/develop/config/logging.php
将此文件添加到您的配置文件夹 https://github.com/laravel/laravel/blob/develop/config/logging.php
and add this to your .env file LOG_CHANNEL=stack
并将其添加到您的 .env 文件中 LOG_CHANNEL=stack
回答by LibraRamis
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.
由于我的 laravel 版本从 5.3 升级到 5.7,我遇到了同样的问题。但是在搜索了一些薄荷糖之后,我找到了解决方案。您只需要按照以下步骤操作即可。
- create logging.php file inside the configfolder.
- Copy code from this Official Linkof Laravel.
- Past this code into your logging.php file.
- run this command -- php artisan config:clear
- 在config文件夹中创建 logging.php 文件。
- 从Laravel 的这个官方链接复制代码。
- 将此代码粘贴到您的 logging.php 文件中。
- 运行这个命令——php artisan config:clear
All done. Happy Coding :)
全部完成。快乐编码:)
回答by Son Nguyen
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
回答by Marco Cazzaro
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.
我最近在我的开发机器中遇到了同样的错误(奇怪的是,在生产机器中没有)。在我的机器我都php 7.1
和php 7.2
安装。查了一下phpinfo()
,发现7.1是默认版本,所以我决定改用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!
在这之后,我再也没有问题了。也许尝试 0755 作为存储文件夹的权限。希望这可以帮助!
回答by nensamuel
After two days of some research, I found a solution on Github.
经过两天的研究,我在 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.
如果您使用 Laravel 5.5.4 到 Laravel 5.6.*,那么您只需安装和配置 Graham Campbell 的异常包即可。
Link: https://github.com/GrahamCampbell/Laravel-Exceptions
链接:https: //github.com/GrahamCampbell/Laravel-Exceptions
This worked perfectly for me on Mac OSX (PHP 7.1.7), Laravel 5.6.22
这在 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)
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)
回答by parisssss
use upgrade guide, and add logging.php
to your config files.
使用升级指南,并添加logging.php
到您的配置文件中。