Change the log level on iOS 10 (Unified Logging) with Console.app

帅比萌擦擦* 提交于 2019-11-27 17:29:59

问题


This is so simple but: how on earth do I set the level of log messages I see in Console.app, if I am trying to use iOS10's new "Unified Logging & Activity Tracing" API?

In other words, if I have code running on iOS like so:

fileprivate let logger = OSLog(subsystem: Bundle.main.bundleIdentifier!, category: "mycategory")

fileprivate func logv(_ s:String) {
    os_log("%@",log:logger,type:.info,s)
}

Then what do I need to do to see the logged messages in Console.app? By default, only log messages of type .error seem to show up.

I am wondering how to do this if I am running code on a device, not in the simulator.

Related:

Xcode 8 - os_log_debug and os_log_info logs are not displayed on new Mac console (unified logging)


回答1:


Hilariously, the answer is that you just go to the Console.app's menu bar and select:

  • Action / Include Info Messages
  • Action / Include Debug Messages




回答2:


Xcode 10.0 beta 6 (likely others too) won’t show debug messages logged from the simulator even after enabling Include Info Messages, Include Debug Messages in the Console.app. AFAIK there is no fix for this.

To see debug logs sent from the simulator you have to stream from a terminal instead:

xcrun simctl spawn booted log stream --debug --predicate 'subsystem == "es.com.jano.Myapp"'


来源:https://stackoverflow.com/questions/41608912/change-the-log-level-on-ios-10-unified-logging-with-console-app

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!