问题描述
我正在调试 JSON 端点,需要查看内部服务器错误.但是,我的 app/storage/logs
目录是空的,而且项目中似乎没有其他专用于日志的目录.我试过用谷歌搜索这个主题无济于事.
I'm debugging a JSON endpoint and need to view internal server errors. However, my app/storage/logs
dir is empty and it seems there are no other directories dedicated to logs in the project. I've tried googling the subject to no avail.
如何启用日志记录(如果尚未启用)并查看日志?
How can I enable logging, if it's not already enabled and view the logs?
推荐答案
确保调试模式开启 - 将
APP_DEBUG=true
添加到 .env 文件或设置环境变量Ensure debug mode is on - either add
APP_DEBUG=true
to .env file or set an environment variable日志文件位于 storage/logs 文件夹中.
laravel.log
是默认文件名.如果日志文件夹存在权限问题,Laravel 就会停止.因此,如果您的端点通常有效 - 权限不是问题.Log files are in storage/logs folder.
laravel.log
is the default filename. If there is a permission issue with the log folder, Laravel just halts. So if your endpoint generally works - permissions are not an issue.如果您的调用甚至无法到达 Laravel 或不是由代码问题引起的 - 检查 Web 服务器的日志文件(检查您的 Apache/nginx 配置文件以查看路径).
In case your calls don't even reach Laravel or aren't caused by code issues - check web server's log files (check your Apache/nginx config files to see the paths).
如果您使用 PHP-FPM,也请检查其日志文件(您可以在 PHP-FPM 池配置中看到日志文件的路径).
If you use PHP-FPM, check its log files as well (you can see the path to log file in PHP-FPM pool config).
这篇关于日志位于何处?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!