如何从iPad/iPhone检索使用os_log记录的消息? [英] How can I retrieve messages logged with os_log from iPad/iPhone?

查看:184
本文介绍了如何从iPad/iPhone检索使用os_log记录的消息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Swift中使用新的统一日志记录API.

I am using the new Unified Logging API in Swift.

因此,我创建了一个记录器并按以下方式使用它:

So I create a logger and use it as below:

let testLogger = OSLog(subsystem: "my.subsystem", category: "test")
os_log("just a test: %@", log: testLogger, type: .error, "error")

如果iOS设备与Mac断开连接,如何检索记录的消息?

How can I retrieve the logged message if the iOS device is disconnected from the Mac?

我知道新的控制台应用程序会在设备连接到Mac时显示记录的消息.但是,我想检索设备与计算机断开连接时记录的消息.我该如何实现?

I know that the new Console application shows messages logged when the device is connected to the Mac. However, I want to retrieve a message that was logged when the device was disconnected from the computer. How can I achieve that?

谢谢.

推荐答案

在iOS 11上,您现在可以捕获sysdiagnose并获得对sysdiagnose的访问权限以通过电子邮件发送(不要通过电子邮件发送,这非常大),或者导出到保管箱/airdrop到您的Mac. 说明.

On iOS 11, you can now capture a sysdiagnose and get access to the sysdiagnose for emailing (don't email this, it's huge), or exporting to dropbox/airdrop to your Mac. Instructions.

要点是:

    按住
  • 增大音量,减小音量并按住电源按钮1.5秒钟,直到屏幕振动.
  • 然后等待长达10分钟,然后在您的iOS 11设备上转到:

Settings > Privacy > Analytics > Analytics Data > sysdiagnose_[xxx] > tap share icon in the nav bar.对我来说,不到一分钟.

Settings > Privacy > Analytics > Analytics Data > sysdiagnose_[xxx] > tap share icon in the nav bar. For me it took less than a minute.

您需要向下滚动到以s开头的数据,然后将其类似于sysdiagnose_2018.12.13_14-16-19-0500_iPhone_OS_iPhone_15G77

You would need to scroll down to the data starts with s and then it will be something like sysdiagnose_2018.12.13_14-16-19-0500_iPhone_OS_iPhone_15G77

然后通过AirDrop共享它.您不再需要电缆和iTunes.

Then share it through AirDrop. You don't need a cable and iTunes anymore.

这篇关于如何从iPad/iPhone检索使用os_log记录的消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆