在设备控制台中查看os_log消息 [英] Viewing os_log messages in device console

查看:788
本文介绍了在设备控制台中查看os_log消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正试图通过统一记录(os_log)从我的应用程序中退出一些

I'm trying to get some logging out of my app through Unified Logging (os_log)

这是日志的初始化:

var osLog : OSLog = OSLog(subsystem: "com.test.testapp", category: "native-tester")

以下是我如何使用它:

os_log("iOS App initialized successfully!", log: osLog, type:.info)

正常调试应用程序时,日志会在控制台输出上正确显示,但是当我查看设备控制台时(在设备和模拟器窗口中显示)我根本看不到它们。

When debugging the app normally, the logs appear properly on the console output, but when I look at the device console (Shown in the "Devices and Simulators" window) I don't see them at all.

这篇文章说你应该配置系统以启用调试日志使用

This article says that you should configure the system to enable the debug logs using

sudo log config --mode "level:debug" --subsystem com.test.testapp

但这似乎没有什么区别。我猜这是因为我正在配置mac来查看日志,而不是iPad。

But that didn't seem to make a difference. I'm guessing it's because I'm configuring the mac to view the logs, not the iPad.

如何查看设备中os_log的ipad / iphone日志控制台?

How do I view the ipad / iphone logs from os_log in the device console?

推荐答案

设备和模拟器窗口仅显示崩溃报告。使用控制台应用程序或终端,通过 log --stream 命令查看实时日志输出。

The "Devices and Simulators" window only shows crash reports. Use the Console app or Terminal, via the log --stream command, to see live log output.

To通过控制台应用程序查看设备的实时日志消息,无论是从Xcode运行还是直接从设备运行:

To see the device's live log messages via the Console app, either when running from Xcode or when running from the device directly:


  • 打开Console.app 。

  • 点击左侧面板中设备下的设备名称。

  • 选择操作,然后从菜单中包含信息消息。如果您还使用 .debug 级别消息,请确保同时选择包含调试消息。 (如果未选择这些项目,控制台将显示 .default .fault .error 仅限级别消息。)

  • Open Console.app.
  • Click on the device's name in the left side panel, under "Devices".
  • Select Action, then Include Info Messages from the menu. If you are also using .debug level messages, make sure to select Include Debug Messages as well. (Without those items selected, the Console displays .default, .fault, and .error level messages only.)

如果仍然没有看到消息,请尝试输入此终端命令配置应用程序的日志记录级别:

If you still don't see the messages, try entering this Terminal command to configure the logging levels for your app:

sudo log config --subsystem com.test.testapp --mode level:debug

这将打开 .debug -level logging子系统com.test.testapp(包括 .info .default 消息)。

This turns on .debug-level logging for subsystem "com.test.testapp" (which includes .info and .default messages).

如果你想要保留消息,而不是默认的仅内存,请同时打开三个级别的持久性,如下所示:

If you want to persist the messages, rather than the default of memory-only, turn on persistence for the three levels at the same time, like so:

sudo log config --subsystem com.test.testapp --mode level:debug,persist:debug

尽管有任何日志设置,但只有崩溃报告才会出现在设备和模拟器窗口中。

Regardless of any log settings, though, only crash reports will appear in the "Devices and Simulators" window.

这篇关于在设备控制台中查看os_log消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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