36

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?

Kristopher Johnson
  • 81,409
  • 55
  • 245
  • 302
  • 2
    Have you figured this out? – Jan Aug 22 '17 at 12:39
  • It's old and I haven't tried it, but you should take a look on this project, perhaps it will do the trick: https://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 – IdoT Jun 04 '18 at 15:09
  • @Jan does my answer help? – Max Coplan Dec 05 '19 at 19:21

2 Answers2

10

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 ‍♀️

Max Coplan
  • 1,111
  • 13
  • 27
  • 2
    This means there really is no option to stream from a device? Crazy .. So we need to use Console.app :/ – smat88dd Oct 28 '20 at 04:42
  • 1
    "--device" option seems only been introduced with mac os 10.15, previously collecting logs from a device was not available? – Dmitry Simkin Oct 28 '20 at 10:50
  • 1
    I get "log: failed to create archive: Device not configured (6)" every time. I don't see a fix anywhere. Any ideas? – Todd Hoff Nov 21 '21 at 06:50
  • 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 – Max Coplan Nov 22 '21 at 19:05
  • 1
    For "failed to create archive" I found this: https://stackoverflow.com/a/70766647/3221771 – Waterloo Stu Dec 16 '22 at 15:01
2

You can, using third-party OSS tools.

https://libimobiledevice.org

These are available using homebrew. brew install libimobiledevice

You can discover available devices using idevice_id and then start streaming logs using idevicesyslog -n -u <duid>

parzival
  • 301
  • 1
  • 7