laravel 日志位于何处?

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

Where are logs located?

laravellogginglaravel-5laravel-5.2

提问by Alexander Lomia

I'm debugging a JSON endpoint and need to view internal server errors. However, my app/storage/logsdir 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.

我正在调试 JSON 端点,需要查看内部服务器错误。但是,我的app/storage/logs目录是空的,似乎项目中没有其他专用于日志的目录。我试过谷歌搜索这个主题无济于事。

How can I enable logging, if it's not already enabled and view the logs?

如何启用日志记录(如果尚未启用)并查看日志?

回答by Denis Mysenko

  • Ensure debug mode is on - either add APP_DEBUG=trueto .env file or set an environment variable

  • Log files are in storage/logs folder. laravel.logis 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.

  • 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).

  • If you use PHP-FPM, check its log files as well (you can see the path to log file in PHP-FPM pool config).

  • 确保调试模式打开 - 添加APP_DEBUG=true到 .env 文件或设置环境变量

  • 日志文件位于 storage/logs 文件夹中。laravel.log是默认文件名。如果日志文件夹存在权限问题,Laravel 就会停止。因此,如果您的端点通常有效 - 权限不是问题。

  • 如果您的调用甚至没有到达 Laravel 或不是由代码问题引起的 - 检查 Web 服务器的日志文件(检查您的 Apache/nginx 配置文件以查看路径)。

  • 如果您使用 PHP-FPM,还要检查其日志文件(您可以在 PHP-FPM 池配置中看到日志文件的路径)。

回答by Ali

You should be checking the root directory and not the app directory.

您应该检查根目录而不是应用程序目录。

Look in $ROOT/storage/laravel.lognot app/storage/laravel.log, where rootis the top directory of the project.

查看$ROOT/storage/laravel.lognot app/storage/laravel.log,其中root是项目的顶级目录。

回答by Luis Cabrera Benito

In Laravel 6, by default the logs are in:

在 Laravel 6 中,默认情况下日志位于:

storage/logs/laravel.log

存储/日志/laravel.log