18

I'm using Console to debug iPhone 7

  • I am seeing <private> on most information. I am able to access Xcode simulator iPhone 7 device which does not show <private>. However I need to debug a passkit pass on the phone.

I think my devices development certificate is in keychain - am I being stupid?

How do you debug a real iPhone with access to full information ?

mfaani
  • 33,269
  • 19
  • 164
  • 293

3 Answers3

40

The detail is coming from Apple's Unified logging. If a debug message is a dynamic string, by default, <private> will be displayed.

In order for the data to print out the actual string, the string must be declared public when sent to logging. For example, in Swift this will display the text sent to the logger, as it's a static string:

static let logger = OSLog(subsystem: "com.company.myApp", category: "myCategory")
os_log(logger, "Some text that will display correctly");

However, this will display Some string: <private>

os_log(logger, "Some string: %s", "text that will display <private>")

In order for the text to display as expected, it would need to be declared with the public tag:

os_log(logger, "Some string: %{public}s", "text that will display as expected")

If you're simply looking at logs for 3rd party applications, then you're not going to be able to view the data, by default.

However, there are some that report that it is possible to see the redacted data with the log command line utility:

sudo log config --mode "private_data:on"

To my knowledge, this is not documented by Apple.

Post Catalina

Note that the above, undocumented switch was broken with the introduction of Catalina. However, it is now possible to reveal 'private' messages with a simple, signed configuration profile, as documented by Howard Oakley, here

TheDarkKnight
  • 27,181
  • 6
  • 55
  • 85
  • Sorry, no. To my knowledge, this isn't available from php. – TheDarkKnight Aug 31 '17 at 13:12
  • 2
    Does that `sudo log config --mode "private_data:on"` work for you? I also need to debug some Apple's process logs such as `apsd` and this `` makes it a lot more difficult. – Jan Sep 13 '17 at 09:22
  • @Jan, it does. I just tried it with apsd; copied the line into Terminal and watched the output in Console, which changed to showing all data. Tested using the Developer Beta 9 of macOS 10.13 – TheDarkKnight Sep 13 '17 at 12:40
  • In my case, I'm trying to see the logs from iOS and not from a macOS app. Do you see the private logs from an iOS app? – Jan Sep 13 '17 at 12:43
  • @Jan, sorry, I don't have an iOS device to test this. – TheDarkKnight Sep 13 '17 at 13:19
  • Note that the daily Swift-syntax-change now requires `os_log("Some string: %{public}s", log:logger, ...` – qwerty_so Oct 28 '18 at 12:50
  • Is public only required in "production"? I'm confused why I can see the output of a dynamic string in Console.app when developing - I haven't specified the string as {public}. This makes sense, otherwise what is the point of ever specifying {public}, but it's not specified in the WWDC sessions or the documentation. – Austin Oct 31 '18 at 21:02
  • @Austin, what SDK are you building against? – TheDarkKnight Nov 15 '18 at 16:40
  • @TheDarkKnight I think it was 10.14, I may have figured out what was going on but can't remember :S. I had a hard time getting `os_log` to work and display in console consistently. – Austin Dec 03 '18 at 23:21
  • You can now do this in Swift: `os_log("\(variable, privacy: .public)")` – David Lawson May 05 '21 at 09:25
4

There is no single setting that you can change for iOS logging as there is for macOS.

If you are running a beta version of iOS, the private log information seems to be collected, so that is one option.

The other option is to see if there is a profile on this page that covers the logging you need.

Once you install the relevant profile you will see the previously <private> information appearing in the iOS console log.

In my case I was able to use the "Baseband" profile to enable caller id logging while working on a CallKit extension.

To disable the private logging you simply remove the profile from general settings on the device.

Paulw11
  • 108,386
  • 14
  • 159
  • 186
0

If you're jailbroken, you can create a plist at /Library/Preferences/Logging/com.apple.system.logging.plist with a bool key Enable-Private-Data set to TRUE.

See https://github.com/EthanArbuckle/unredact-private-os_logs for more information.