gpt4 book ai didi

swift - 如何打开/查看存储在设备上的 iOS OSLogs?

转载 作者:搜寻专家 更新时间:2023-11-01 05:49:50 33 4
gpt4 key购买 nike

我正在使用 Apple 的 os.log 框架创建日志。我只是在制作日志:

os_log("Update: Lat: %{public}f | Long:  %{private}f | RemainingTime: %{public}f ", log: log, type: .default, location.coordinate.latitude, location.coordinate.longitude, UIApplication.shared.backgroundTimeRemaining).

我确实在控制台和调试器中看到了日志。

我读过 this并且我能够成功地下载容器(只是不确定容器是否包含我正在寻找的内容或者这是否是正确的查看位置)。然后我点击 Show packages:

但之后我只看到:

enter image description here

我查看了所有文件。这些文件只包含如下数字:

enter image description here

我应该做些额外的事情还是找错地方了?


EDIT1:在 JAL 的建议之后:

我调查了(文档、图书馆、tmp)。有plistktx 文件。和 function.data & map.data 文件。

我查看了这些文件:

enter image description here

还有这些文件:

enter image description here

我尝试用控制台打开它们,但得到如下图所示的乱码结果:

enter image description here


编辑 2:

所以首先我没有权限打开/var/db/diagnostics,我必须执行sudo bash。然后我执行了 cd/var/db/diagnostics 并看到了这些文件。

Events
FaultsAndErrors
Oversize
SpecialHandling
StateDumps
TTL
logdata.Persistent.20170724T212501.tracev3
logdata.Persistent.20170725T015616.tracev3
logdata.Persistent.20170725T134017.tracev3
logdata.Persistent.20170725T171020.tracev3
logdata.Persistent.20170725T213354.tracev3
logdata.Persistent.20170726T002702.tracev3
logdata.Persistent.20170726T144412.tracev3
logdata.Persistent.20170726T202128.tracev3
logdata.Persistent.20170727T021506.tracev3
logdata.Persistent.20170727T033929.tracev3
logdata.Persistent.20170727T075325.tracev3
logdata.Persistent.20170727T145233.tracev3
logdata.statistics.0.txt
logdata.statistics.1.txt
shutdown.log

然后我做了 open -a console logdata.Persistent.20170725T015616.tracev3(我也尝试了其他 .tracev3 文件),但控制台只是打开并开始跟踪实时,就好像我刚刚正常打开控制台一样......

最佳答案

您没有在问题中指定 iOS、macOS 或 tvOS,因此我的回答在所有平台上都是通用的。

评论 WWDC 2016 - Session 721 - Unified Logging and Activity Tracing .

记录数据以新的压缩二进制格式(.tracev3.logarchive 文件)存储,这就是那些“数字”。您必须使用 Console.app 或 log 命令行工具打开这些文件。

您在错误的位置查找日志文件。来自 session 视频:

Those files are now stored under /var/db/diagnostics with additional supporting files in /var/db/uuidtext. There are new tools to access that data, there's a new Console, a new log command line tool and one of the things you have to keep in mind is because the data is now stored in a binary format you must use the new tools to access it. So you can no longer grep through logs you have to use our tools to do the surfing through it.

There's also another new type of file the .logarchive, which is there for portability of log data. Essentially a .logarchive is a collection of information out of /var/db/diagnostics and you uuidtext collected together into a single file that's easier to transfer to email, to attach to bug reports and the like.

如果您将 stdout 或 stderr 重定向到一个文件(例如 this example 中的代码),它应该位于应用程序沙箱的 Documents 目录中(或您指定的任何目录)。写入/var/db/diagnostics 的日志通常对 iOS 和 tvOS 上的最终用户不可用。

关于swift - 如何打开/查看存储在设备上的 iOS OSLogs?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45353818/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com