Episode #346

Streaming Logs with the log Tool

Series: Unified Logging and Activity Tracing

5 minutes
Published on July 12, 2018

This video is only available to subscribers. Get access to this video and 555 others.

Console.app is a nice way of viewing logs, but most of this power (and more) is builtin to the log utility from the command line. In this episode we will see how to stream debug logs from the simulator, as well as how to retrieve logs from customer or tester devices out in the field by triggering a sysdiagnose.

Episode Links

Streaming Logs from your Mac

To stream logs from the terminal, use the log stream command in Terminal. You can influence the level of logs you get back by using

log stream --debug


log stream --info

Streaming Logs from the Simulator

Doing the above will not include logs in the iOS Simulator. To stream these logs, you have to run the log utility within the booted simulator.

We can use simctl to do this:

xcrun simctl spawn booted log ...

Filtering Based on Subsystem

If we want to limit the output just to one subsystem, we can filter using the --predicate flag:

xcrun simctl spawn booted log stream --debug --predicate 'subsystem == "com.ficklebits.UnifiedLoggingDemo"'

Note that this takes an NSPredicate type string, so you can do things like "subsystem CONTAINS[cd] 'foo'", filter on category, or any of the other fields available to you.

This episode uses Xcode 10.0-beta2.