Apple iPhone - debugging with console - <private>?

9.6k views Asked by At

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 ?

3

There are 3 answers

12
TheDarkKnight On

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

2
Claus Jørgensen On

You can add this to your Info.plist to not have the arguments redacted when you don't have a debugger attached:

<key>OSLogPreferences</key>
<dict>
    <key>your.subsystem.key.here</key>
    <dict>
        <key>your-category-here</key>
        <dict>
            <key>Enable-Private-Data</key>
            <true/>
        </dict>
    </dict>
</dict>
0
Paulw11 On

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.