9

I am using the new Unified Logging API in Swift.

So I create a logger and use it as below:

let testLogger = OSLog(subsystem: "my.subsystem", category: "test")
os_log("just a test: %@", log: testLogger, type: .error, "error")

How can I retrieve the logged message if the iOS device is disconnected from the Mac?

I know that the new Console application shows messages logged when the device is connected to the Mac. However, I want to retrieve a message that was logged when the device was disconnected from the computer. How can I achieve that?

Thank you.

mfaani
  • 33,269
  • 19
  • 164
  • 293
jair.jr
  • 597
  • 1
  • 7
  • 13

3 Answers3

10

On iOS 11, you can now capture a sysdiagnose and get access to the sysdiagnose for emailing (don't email this, it's huge), or exporting to dropbox/airdrop to your Mac. Instructions.

The gist of it is :

  • hold down volume up and volumn down and power button for 1.5 seconds until the screen vibrates.
  • then wait for upto 10 minutes and on your iOS 11 device go to:

Settings > Privacy > Analytics > Analytics Data > sysdiagnose_[xxx] > tap share icon in the nav bar. For me it took less than a minute.

Search the logs for sysdiagnose. It will be something like sysdiagnose_2018.12.13_14-16-19-0500_iPhone_OS_iPhone_15G77

Then share it through AirDrop. You don't need a cable and iTunes anymore.

mfaani
  • 33,269
  • 19
  • 164
  • 293
Daniel
  • 23,129
  • 12
  • 109
  • 154
  • Do you mean that unlike cocoalumberjack where I'm can send the logs through email I'm unable to that for oslog? – mfaani Dec 13 '18 at 17:21
  • @Honey the sysdiagnose log is about 300 MB in size. Most email clients wouldn't let you send something that large. – theoriginalbit Dec 20 '18 at 02:50
  • Now, you must not press and hold for 1.5 seconds, it's 250ms now. Apple says: Trigger a sysdiagnose by simultaneously pressing and releasing both volume buttons + the Side (or Top) button for 250 milliseconds. Holding too long (>1s) will lock the device instead. – Almas Adilbek Oct 05 '22 at 17:40
3

The only way I have been able to uncover is to trigger a sysdiagnose on the iOS device, then connect it to a computer and let it sync with iTunes, then gather the logs from the filesystem.

To trigger a sysdiagnose on an iOS device you need to press the volume up, volume down and power buttons at the same time. Then wait for it to finish. Apple says "10 minutes". Then connect to a computer and sync with iTunes.

The logs are on macOS here:

~/Library/Logs/CrashReporter/MobileDevice/[Your_Device_Name]/DiagnosticLogs/sysdiagnose

On Windows, I am not sure.

More details in Apple sysdiagnose intructions

Nicolai Henriksen
  • 1,324
  • 1
  • 13
  • 37
  • Do you mean that unlike cocoalumberjack where I'm can send the logs through email I'm unable to that for oslog? – mfaani Dec 13 '18 at 17:20
  • It is huge so you cannot email, but look at [Daniels answer](https://stackoverflow.com/a/46497201/833197). – Nicolai Henriksen Dec 15 '18 at 16:59
  • lol. See Nicoali answer's edit history. I'm trying to find a way where the user can just grab the os.log files and send it through email. sysdiagnose is not what I want – mfaani Dec 15 '18 at 17:19
  • @Honey So did you find another way? – matt Feb 25 '19 at 02:23
  • @matt No. See the [this](https://chat.stackoverflow.com/rooms/185272/discussion-between-honey-and-jal) discussion – mfaani Feb 25 '19 at 03:07
1

Original answer from here

The current steps in iOS14 are like this:

Settings > Accessibility > Touch >> Assistive Touch >> Single Tap >> Analytics

Finally, touch the button. Sysdiagnose will start.

enter image description here

Once you’re done. Disable it, because you don’t want to constantly trigger that sysdiagnose…

mfaani
  • 33,269
  • 19
  • 164
  • 293