Unity 为编辑器、包管理器、许可、开发版播放器和 Hub 生成日志文件。您可以使用这些日志文件了解应用程序中任何问题发生的位置。
Unity 将来自控制台窗口Unity 编辑器窗口,显示 Unity 或您自己的脚本生成的错误、警告和其他消息。 更多信息
参见 术语表的所有消息、警告和错误添加到日志文件中。要将您自己的消息添加到控制台窗口和日志中,请使用Debug 类。
每个操作系统都将日志文件存储在不同的位置。本页面概述了默认位置,但您也可以使用某些命令行参数来控制 Unity 生成日志文件的时间和位置。有关更多信息,请参阅命令行参数文档。
注意:并非所有平台都支持此功能。有关更多信息,请参阅平台特定文档。
您可以从控制台窗口访问编辑器日志。为此,请打开控制台窗口(菜单:窗口 > 常规 > 控制台)并从控制台窗口菜单中选择打开编辑器日志。
您可以使用操作系统的文件管理器应用程序访问其他日志。
日志类型 | 日志位置 |
---|---|
编辑器 | ~/.config/unity3d/Editor.log |
包管理器 | ~/.config/unity3d/upm.log |
许可客户端 | ~/.config/unity3d/Unity/Unity.Licensing.Client.log |
许可审计 | ~/.config/unity3d/Unity/Unity.Entitlements.Audit.log |
在 macOS 上,您还可以通过 Console.app 实用程序访问 Unity 的日志
日志类型 | 日志位置 |
---|---|
编辑器 | ~/Library/Logs/Unity/Editor.log |
包管理器 | ~/Library/Logs/Unity/upm.log |
许可客户端 | ~/Library/Logs/Unity/Unity.Licensing.Client.log |
许可审计 | ~/Library/Logs/Unity/Unity.Entitlements.Audit.log |
在 Windows 上,包管理器和编辑器日志放置在默认情况下 Windows 资源管理器中未显示的文件夹中。要查看 AppData 文件夹,您必须在 Windows 上启用“隐藏的项目”设置。有关如何执行此操作的更多信息,请参阅 Microsoft 有关在 Windows 中查看隐藏的文件和文件夹的文档。
在 Windows 上,默认情况下不存在标准输出流,因此您必须从 CI 系统作为子进程启动具有有效配置的 stdout
流的编辑器。如果您指定 -
将输出发送到 stdout
,则您不会在控制台窗口中看到输出。
日志类型 | 日志位置 |
---|---|
编辑器 | %LOCALAPPDATA%\Unity\Editor\Editor.log |
包管理器 | 用户帐户:%LOCALAPPDATA%\Unity\Editor\upm.log SYSTEM 帐户: %ALLUSERSPROFILE%\Unity\Editor\upm.log |
许可客户端 | %LOCALAPPDATA%\Unity\Unity.Licensing.Client.log |
许可审计 | %LOCALAPPDATA%\Unity\Unity.Entitlements.Audit.log |
崩溃文件 |
%TMP%\CompanyName\ProductName\Crashes 注意:您可以使用 -crash-report-folder 命令行参数覆盖文件夹位置。 |
要查看播放器日志,请打开控制台窗口(菜单:窗口 > 常规 > 控制台)并从控制台窗口菜单中选择打开播放器日志。您还可以导航到以下文件夹
操作系统 | 播放器日志由独立播放器创建的 .log 文件,其中包含事件记录,例如脚本执行时间、编译器版本和 AssetImport 时间。日志文件可以帮助诊断问题。 更多信息 参见 术语表位置 |
---|---|
Android | 要访问 Android 应用程序的播放器日志,请使用Android logcat。有关更多信息,请参阅查看 Android 日志。 |
iOS | 使用 GDB 控制台或通过 XCode 的 Organizer 控制台访问 iOS 设备日志。有关设备日志的更多信息,请参阅Apple 的文档。 |
Linux | ~/.config/unity3d/CompanyName/ProductName/Player.log |
macOS |
~/Library/Logs/Company Name/Product Name/Player.log 注意:您还可以使用 Console.app 实用程序查找日志文件。 |
通用 Windows 平台 | %USERPROFILE%\AppData\Local\Packages\<productname>\TempState\UnityPlayer.log |
Web | Unity 将日志输出写入您的浏览器的 JavaScript 控制台。 |
Windows | %USERPROFILE%\AppData\LocalLow\CompanyName\ProductName\Player.log |
您可以使用操作系统的文件管理器应用程序访问 Hub 日志。您也可以从 Hub 内部访问这些日志。有关更多信息,请参阅Hub 文档。
操作系统 | 播放器日志位置 |
---|---|
Linux | ~/.config/UnityHub/logs/info-log.json |
macOS | ~/Library/Application\ Support/UnityHub/logs/info-log.json |
Windows | %UserProfile%\AppData\Roaming\UnityHub\logs\info-log.json |
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.