首页 > 解决方案 > Laravel:500 服务器错误但没有错误日志?

问题描述

我通过 Laravel 遇到了 500 服务器错误,并且没有错误被写入日志文件。我已经验证权限没问题,并且 Laravel 可以写入日志文件。我不确定我在这里还有什么其他选择。

我已经将错误追到了这个类,注释掉的行是导致错误的行。

class CollectionResource extends JsonResource
{
    public function toArray($request)
    {
        return [
            'id' => $this->id,
            'name' => $this->name,
            // 'member_count' => $this->items()->count(),
            // 'member_count_today' => $this->items()->whereDate('collection_entries.created_at', Carbon::today()->toDateString())->count(),
            // 'member_images' => $this->items->take(10)->pluck('data.picture'),
            'created_at' => $this->created_at,
            'updated_at' => $this->updated_at,
        ];
    }
}

该错误相当零星,并不总是发生。

标签: phplaravel

解决方案


先运行这个命令

php artisan optimize:clear 

应用程序/配置/app.php

'debug' => true, //env('APP_DEBUG'),

检查 .env 文件,确保权限设置正确,如果文件夹不存在,则手动创建 storage/logs 文件夹。


推荐阅读