我默认在Laravel 5.5上启用了日志记录。
设置为:
在config/app.php
文件中:
'log' => env('APP_LOG', 'single'),
'log_level' => env('APP_LOG_LEVEL', 'debug'),
在.env
文件中:
APP_LOG_LEVEL=debug
如果应用程序发生任何错误,我可以看到异常页面。但是我不再在日志文件中看到它。几个月前,它运行良好。即使我尝试手动登录,它也不会记录。
Log::debug('Notification');
我有使用Storage
创建文件的代码,它工作正常。因此,我认为这不是许可问题。这可能是什么原因?
答案 0 :(得分:1)
尝试
php artisan config:cache
如果问题与laravel应用程序缓存有关,那么artisan命令将帮助将所有配置文件(具有当前更改)缓存到单个文件中。在laravel中,配置值是从应用程序缓存中获取的,因此,每当更改配置文件时,都必须运行此命令。用最新更改更新应用程序缓存。
如果该问题与应用程序缓存无关,则可以使用apache2错误日志跟踪真正的原因。
tail -f /var/log/apache2/error.log
答案 1 :(得分:1)
您可能已授予存储文件夹而不是内部文件夹的权限和所有权,例如:在redhat上进行案例处理,因为在redhat的情况下apache用户是apache,在debian或大多数其他www-data情况下
folder | Permission | ownership
storage | 775 | root:apache
storage/logs | 755 | root:apache
storage/logs | 775 | root:root
应该最小
storage/logs | 775 | root:apache
or
storage/logs | 755 | apache:apache
,请与 APP_DEBUG = true
答案 2 :(得分:0)
这里有两件事:
.env
文件中是否确实包含以下内容,
基本上检查它是否不是假值。:APP_LOG=daily
storage
目录对服务器用户可写:chmod -R 755 storage
答案 3 :(得分:0)
可能您不小心更改了默认日志路径或配置数组中的任何内容
'single' => [
'driver' => 'single',
'path' => storage_path('logs/laravel.log'),
'level' => 'debug',
],
答案 4 :(得分:0)
将文件许可权更改为777,如果日志文件中存在错误,则为许可。您可以使用以下命令检查用户运行的php:
ps aux | egrep'(apache | httpd)'
并更正文件权限。
如果该问题不是获得许可的,则可以在写入日志文件的代码行之后使用error_get_last()并查看错误是什么。
如果没有错误,则可能是配置中的写入日志文件的地址不正确
答案 5 :(得分:0)
确保将日志级别设置为调试,并记住在更改该值后清除配置缓存
.env file
APP_LOG_LEVEL=debug
run in console
php artisan config:cache
答案 6 :(得分:0)
我发现了问题。我正在使用Bugsnag(用于生产),并且已经在项目中对其进行了设置。
当我集成它时,我使用了它在其仪表板上的说明,我相信这些说明还不完善,因为他们在其documentation上有此说明。因此,我在应用程序服务提供商app / Providers / AppServiceProvider.php的register方法中添加了以下代码。
---
output:
pdf_document:
keep_tex: yes
# latex_engine: xelatex
header-includes:
# - \usepackage{nath}
- \usepackage{amsmath}
title: "Test Report"
toc: true
number_sections: true
graphics: yes
toc_depth: 2
df_print: kable
fontsize: 12pt
editor_options:
chunk_output_type: console
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
## R Markdown
This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see <http://rmarkdown.rstudio.com>.
When you click the **Knit** button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
```{r cars}
summary(cars)
```
**`r 5 * 20`** entries in the dataset;
Testing mathematical symbols, $\varepsilon_{u,i}$.
The formula used for this is:
$$Y_{u,i} = \mu + \varepsilon_{u,i}$$
Where $Y_{u,i}$ is the predicted rating per user, per movie and $\mu$ is the "true" rating for all movies. Mu-hat -> $\hat{mu}$.
## Including Plots
You can also embed plots, for example:
```{r pressure, echo=FALSE}
plot(pressure)
```
Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing of the R code that generated the plot.
在我的本地环境中,我没有在$this->app->alias('bugsnag.logger', \Illuminate\Contracts\Logging\Log::class);
$this->app->alias('bugsnag.logger', \Psr\Log\LoggerInterface::class);
文件中设置BUGSNAG_API_KEY
。因此,既没有将异常发送到Bugsnag,也没有登录到本地laravel.log文件。
当我将Bugsnag集成到在Laravel 6上运行的另一个项目时,我怀疑此问题并检查了文档。在那里,我找到了继续登录到原始记录器和Bugsnag所需的代码。
.env