21

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)

Axel Guilmin
  • 11,454
  • 9
  • 54
  • 64
algal
  • 27,584
  • 13
  • 78
  • 80
  • Did you watch the WWDC 2016 video on this topic? Everything I know about this is what's said in that video... – matt Jan 30 '17 at 17:47
  • I did watch it. Amazingly, I did not find anything in that video that answers this question. But I must be missing something obvious, because this is pretty basic stuff. – algal Jan 30 '17 at 18:01
  • More questions that were not answered by the WWDC2016 video introducing this API: https://forums.developer.apple.com/message/208800#208800 – algal Jan 30 '17 at 18:02
  • 2
    I don't know that you're missing anything, though. I found the video largely, shall we say, aspirational... – matt Jan 30 '17 at 18:04
  • Do you not just use the search field? Search for the type you want, press return and change search text from searching for "Any" to searching for "Message Type" – jjatie Jan 30 '17 at 18:45
  • You can then save your searches for quick reference. – jjatie Jan 30 '17 at 18:46
  • @jjatie does not solve the problem that messages with log level of "info" do not seem to appear at all, which is what I'm wondering about. – algal Jan 30 '17 at 19:16
  • @algal I figured since searching for "default" and "error" worked... – jjatie Jan 30 '17 at 19:22

2 Answers2

21

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

enter image description here

Axel Guilmin
  • 11,454
  • 9
  • 54
  • 64
algal
  • 27,584
  • 13
  • 78
  • 80
  • omg, I was looking into Console.app and didn't check that menu. – Sulthan Feb 02 '17 at 21:18
  • 3
    One 500 bounty question here. One Apple DTS ticket. One dev forums post. One question on slack boards. And finally this. No one knew. This means something but I do not know what. – algal Feb 03 '17 at 05:58
11

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"'
Jano
  • 62,815
  • 21
  • 164
  • 192
  • 1
    [This article](https://www.iosdev.recipes/simulator/os_log/) suggests it is not a bug but is intended behavior, that this is because "the 'system' log level [of the Simulator] is set `info`". This suggests maybe we could workaround this if we knew how to change the system log level of iOS running in the Simulator. – algal Mar 10 '19 at 22:03