iosloggingmacos-sierra

Can you use macOS "log stream" or "log show" to get messages from connected iOS devices?


With the introduction of "Unified Logging" in macOS 10.12 Sierra, one can use the log command to view system log messages in a terminal. For example

sudo log stream

or

sudo log stream --process `pgrep -f /usr/local/bin/myprogram` --info --debug

or

log show --predicate 'process == "myprogram"' --last 1h --info --debug

Using the new "unified" Console.app, one can view system messages and can also view messages from connected iOS devices.

Is there any way to use the log command or any other command-line interface to view iOS device messages in Terminal, or to send them to a file? Or is Console.app the only way?


Solution

  • tl;dr: log collect --device

    log collect --device lets you retrieve log archives that can be passed into log show --archive system_logs.logarchive with all the options you're familiar with.

    Use log collect --device to automatically guess the device you're referring to. log collect device-name="Maxs iPhone" or log collect device-udid=abcdefg to collect from a particular device.

    log collect --output /your/path will save it to your specified file name or directory. If --output is not given, your output will be in the current directory as system_logs.logarchive.

    Note: I occasionally get errors about log: failed to create archive: Device not configured (6) or log: failed to create archive: Connection reset by peer (54) but if I just rerun the command it'll sometimes work 🤷🏾‍♀️