Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to see iOS device logs in Console app using os_log

I want to test my app when it is not launched via Xcode, but rather by launching directly from the springboard. And I want to see log messages as I do that.

I'm not having any trouble seeing console logs for the simulator using os_log. It's great, because my category and subsystem let me filter to see exactly the messages I want to see in the Console app:

enter image description here

Now I want to do this on my device. I can see my connected device listed in the Console app:

enter image description here

But I don't see any of my app's os_log or print messages in the Console app. Is this just not a supported thing? Is there a way to log to the Console app from my device? Is there any way to log from my app running independently on the device?

EDIT Curiouser and curiouser. Now I'm able to see some of my app's os_log messages in the Console while the app runs independently on the device:

enter image description here

The catch, however, is that word "some". It seems to start working for a while and then it just mysteriously stops again. It's as if the pipeline from the device to the Console is unreliable.

So now the question becomes: is there any way to log reliably from my app running independently on the device?

like image 285
matt Avatar asked Nov 13 '17 16:11

matt


1 Answers

This is not a complete answer, but a large part of the trick seems to be this:

In Xcode's Devices and Simulators window, locate the device and show the console display by tapping the tiny button at the lower left.

enter image description here

It appears that this somehow opens the floodgates and allows the stream of log events to pass through to the Console app. It still isn't 100% reliable; eventually the stream can be mysteriously shut off, and I have the impression that events are randomly omitted now and then. But it seems to be a sine qua non for getting the stream to flow at all.

like image 93
matt Avatar answered Oct 09 '22 20:10

matt