如何在没有日志、没有信息的情况下调试 Laravel 错误 500

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/44921945/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 16:15:49  来源:igfitidea点击:

How to debug Laravel error 500 with no logs, no information

phplaravelerror-handling

提问by Gauthier

I'm working on an existing Laravel application in order to develop new feature but after installing the app on my computer, I have an error 500 and no clue to resolve it.

我正在处理现有的 Laravel 应用程序以开发新功能,但在我的计算机上安装该应用程序后,出现错误 500 并且没有解决方法。

In my app.php file I have set :

在我的 app.php 文件中,我设置了:

'env' => env('APP_ENV', 'local'),
'debug' => env('APP_DEBUG', true),

But still I have no information, no logs are generated in storage/logs. I have no idea of what could be the problem.

但是我仍然没有任何信息,也没有在storage/logs. 我不知道可能是什么问题。

The previous developer was on windows and I'm working on Linux but I'm not sure this is revelant.

以前的开发人员在 Windows 上工作,我在 Linux 上工作,但我不确定这是否相关。

EDIT:

编辑:

I also have those variable in my config/app.php

我的 config/app.php 中也有这些变量

'log' => env('APP_LOG', 'daily'),
'log_level' => env('APP_LOG_LEVEL', 'debug'),

采纳答案by lehel

Next to looking into your .envfile, make sure permissions are correctly set (and good practice to create the storage/logsfolder(s) manually - at least on windows that causes problems).

接下来查看您的.env文件,确保权限设置正确(以及storage/logs手动创建文件夹的良好做法- 至少在导致问题的 Windows 上)。

回答by user6392101

Some PHP exceptions are not possible to catch, so Laravel cant handle them. For example syntax errors, or maximum memory limit errors.

有些 PHP 异常是无法捕获的,所以 Laravel 无法处理它们。例如语法错误或最大内存限制错误。

The following error types cannot be handled with a user defined function: E_ERROR, E_PARSE, E_CORE_ERROR, E_CORE_WARNING, E_COMPILE_ERROR, E_COMPILE_WARNING, and most of E_STRICT raised in the file where set_error_handler() is called.

用户定义的函数无法处理以下错误类型:E_ERROR、E_PARSE、E_CORE_ERROR、E_CORE_WARNING、E_COMPILE_ERROR、E_COMPILE_WARNING,以及在调用 set_error_handler() 的文件中引发的大部分 E_STRICT。

Ref.: http://php.net/manual/en/function.set-error-handler.php

参考:http: //php.net/manual/en/function.set-error-handler.php

回答by Ritesh

I tried to everything to find out the issue like enabling error reporting to report all like :

我竭尽全力找出问题,例如启用错误报告以报告所有内容,例如:

ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

Also i tried to add my custom error handler as well but nothing worked for me. So finally i found the actual issue in php error log file in apache error logs folder (Applications/MAMP/logsas am using Mac).

我也尝试添加我的自定义错误处理程序,但没有任何效果。所以最后我在 apache 错误日志文件夹中的 php 错误日志文件中找到了实际问题(Applications/MAMP/logs因为我使用的是 Mac)。