Retrieving Logs from a Customer's Device

We tried to adopt OSLog in past years, but it was really cumbersome to retrieve the logs from customers.

Doing a sysdiagnose is a really cumbersome task for most non-technical users to perform. Additionally they contain WAY more information than we need and are generally very large.

This is true for macOS and iOS apps.

Are there any new facilities for retrieving just the logs for a given subsystem that we could trigger with code, for instance in a help menu?
Answered by DTS Engineer in 668567022
So, let’s start with some history:
  • macOS programs have been able to read log messages since the introduction of OSLogStore on macOS 10.15.

  • This API is not available on iOS-based platforms.

  • In iOS 14 beta we added the OSLog framework to the iOS SDK, along with a new initialiser to OSLogStore that allowed iOS apps to read their own log messages.

  • Unfortunately this feature didn’t work properly )-: and so it was removed very late in the iOS 14 beta cycle.

  • It’s now several months later and the feature has not returned (up to and including iOS 14.5b5).

I have no concrete info to share about when this feature will return; in fact, I can’t even confirm that it will return [1]. What I can say is that the OSLog team are well aware of the demand for this feature from third-party developers.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

[1] My management gets grumpy if I start speculating about The Future™, and if there’s one thing that this saga should tell you is that even the best laid plans are subject to last minute changes.
To add on a bit, what is the best way to get a log archive from a tester's device when they *don't* have access to Xcode? The specific instance that's been most troublesome for me has been when TestFlight users have a build, but aren't otherwise familiar - or after a beta when it's in the hands of a customer directly.
@heckj: a tester with access to a Mac can use log collect --device as seen in the talk to get a logarchive, even if they do not have Xcode. Using --start or --last limits the time range of the logs, which can limit the size of the resulting logarchive.
I went through a similar thing before WWDC this year. I wanted to start using unified logging but there is so much friction for an end user to send logs to a developer. I understand how it can be "simple" for a developer to connect their device to their Mac and run a terminal command to capture the logs.

But for an end user, think of how many of them might now have a Mac, have never opened Terminal, etc. There is no feasible way I can retrieve logs from them currently using OSLog.

There needs to be some ability to retrieve these logs directly on a device that the end user can send in an email or similar fashion. Some API that we can call that allows us to specify to "retrieve logs from past x minutes" or similar. I've created an enhancement request and would recommend anyone else do the same because I think this is something greatly needed to increase the usage of OSLog.
Accepted Answer
This new initializer on the OSLog framework’s OSLogStore class might help, but unfortunately many developers are experiencing a bug with it in beta 1, so you might not be able to assess its suitability right away.

(There are some doc comments in the OSLog/Store.h header.)
From what I understand OSLogStore is only available on macOS 11?
@bens OSLogStore is marked available in iOS 14: https://developer.apple.com/documentation/oslog/oslogstore?changes=latest_minor

Unfortunately, there is an issue with retrieving entries (the which I asked about during labs and have filed a Feedback Request for. Please duplicate if you get a chance!:
FB7787937

This is for the error message:
Code Block language
Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service on pid 0 named com.apple.OSLogService was invalidated."


I think it would be helpful to clarify the intended availability as some methods such as [getEntries(with:at:matching:)
](https://developer.apple.com/documentation/oslog/oslogstore/3204125-getentries) are marked as only available on macOS.
With iOS 14 beta 4, the error message has changed from
Code Block text
Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service on pid 0 named com.apple.OSLogService was invalidated." UserInfo={NSDebugDescription=The connection to service on pid 0 named com.apple.OSLogService was invalidated.}

to
Code Block text
Caught error: Error Domain=OSLogErrorDomain Code=9 "Client lacks entitlement to perform operation" UserInfo={NSLocalizedDescription=Client lacks entitlement to perform operation, _OSLogErrorInternalCode=14}


It doesn't appear that my Feedback (FB7868256) has been looked at, but, is this being fixed?

So, let’s start with some history:
  • macOS programs have been able to read log messages since the introduction of OSLogStore on macOS 10.15.

  • This API is not available on iOS-based platforms.

  • In iOS 14 beta we added the OSLog framework to the iOS SDK, along with a new initialiser to OSLogStore that allowed iOS apps to read their own log messages.

  • Unfortunately this feature didn’t work properly )-: and so it was removed very late in the iOS 14 beta cycle.

  • It’s now several months later and the feature has not returned (up to and including iOS 14.5b5).

I have no concrete info to share about when this feature will return; in fact, I can’t even confirm that it will return [1]. What I can say is that the OSLog team are well aware of the demand for this feature from third-party developers.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

[1] My management gets grumpy if I start speculating about The Future™, and if there’s one thing that this saga should tell you is that even the best laid plans are subject to last minute changes.
Retrieving Logs from a Customer's Device
 
 
Q