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

2

39

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?

Hyo answered 9/2, 2017 at 19:29 Comment(3)
Have you figured this out? – Lagoon
It's old and I haven't tried it, but you should take a look on this project, perhaps it will do the trick: github.com/benvium/libimobiledevice-macosx Also, please note it's not part of the unified logger, it's just another tool to grep using terminal instead of console – Coroneted
@Lagoon does my answer help? – Harlequin
H
11

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 πŸ€·πŸΎβ€β™€οΈ

Harlequin answered 12/11, 2019 at 0:17 Comment(5)
This means there really is no option to stream from a device? Crazy .. So we need to use Console.app :/ – Schoolmistress
"--device" option seems only been introduced with mac os 10.15, previously collecting logs from a device was not available? – Infusionism
I get "log: failed to create archive: Device not configured (6)" every time. I don't see a fix anywhere. Any ideas? – Mecklenburg
Do you have it set as a development device? Connect the device via Lightning to your Mac, open Xcode and go to "Devices and Simulators", and try adding your iOS device – Harlequin
For "failed to create archive" I found this: https://mcmap.net/q/410115/-how-to-collect-logs-from-iphone-correctly-and-how-to-resolve-this-error-failed-to-create-archive – Fluor
W
2

You can, using third-party OSS tools.

https://libimobiledevice.org

These are available using homebrew. brew install libimobiledevice

You can discover available devices (UDIDs) by running idevice_id. Then start streaming logs by running idevicesyslog -n -u <udid>

Winstead answered 21/12, 2022 at 16:57 Comment(0)

© 2022 - 2025 β€” McMap. All rights reserved.