php - Log file is not being written in Laravel 5.5
问题描述
I have logging enabled by default on Laravel 5.5.
The settings are:
In config/app.php
file:
'log' => env('APP_LOG', 'single'),
'log_level' => env('APP_LOG_LEVEL', 'debug'),
In .env
file:
APP_LOG_LEVEL=debug
If any error happens on the application, I can see the exception page. But I don't see it in the log file anymore. It was working fine a couple of months ago. Even when I try to log manually, it does not log it.
Log::debug('Notification');
I have code to create files using Storage
and it's working fine. So, I don't think it's some permission issue. What could be the reason behind this?
解决方案
我发现了这个问题。我正在使用 Bugsnag(用于生产)并且我已经在项目中设置了它。
当我集成它时,我使用了它在仪表板上的说明,我认为这并不完整,因为他们在他们的文档中有它。因此,我在我的应用程序服务提供者 app/Providers/AppServiceProvider.php 的注册方法中添加了以下代码。
$this->app->alias('bugsnag.logger', \Illuminate\Contracts\Logging\Log::class);
$this->app->alias('bugsnag.logger', \Psr\Log\LoggerInterface::class);
在我的本地环境中,我没有BUGSNAG_API_KEY
在我的.env
文件中设置。因此,它既没有将异常发送到 Bugsnag,也没有登录到本地 laravel.log 文件。
当我将 Bugsnag 集成到另一个在 Laravel 6 上运行的项目时,我怀疑这个问题并检查了文档。在那里我找到了保持记录到我的原始记录器以及 Bugsnag 所需的代码。
$this->app->alias('bugsnag.multi', \Illuminate\Contracts\Logging\Log::class);
$this->app->alias('bugsnag.multi', \Psr\Log\LoggerInterface::class);
推荐阅读
- r - 根据唯一值将多个 data.table 列粘贴到单个列中
- c# - 如何在 Winform PropertyGrid 中使用多选属性时添加到集合
- html - 使用像 iOS 13 新 UI 一样的 html 和 css 顶部带有透明文本的模糊图像
- database - 你能在 AWS 上得到一个 sqlite3 数据库吗?
- c# - C# 接口和类。接口需要的类中使用的变量不能是私有的,也不能是私有的,只能是公共的。为什么?
- java - a.charAt(i) 是如何越界的?什么不见了?
- database - PostgreSQL 中表数的 O(n) 操作是什么?
- c# - 将字符串拆分为临时表时,从临时表中搜索的存储过程不起作用
- javascript - 在反应虚拟化表(多网格)上手动设置滚动量
- java - 如何检查数字是否高于 Java 中的 Integer.MAX_VALUE,当添加一些其他数字时?