Xcode 15 - Structured logging in console hides interpolation?

Keep in mind I'm talking about interpolated values when logging from within Xcode 15, not Console.app. Also, I'm running on MacOS 13.5, not Sonoma.

If I have something like this in my code:

let log = Logger(subsystem: "com.whatever.MyApp" category: "UI")

And somewhere else in the code do something like:

log.debug("Clicked edit for '\(account.name)'.")

I expect to see the following in Xcode 15's new structured console log:

Clicked edit for 'MyAccount'.

But instead, I see:

Clicked edit for ''.

In order to make the account name appear, I have to use an explicit privacy modifier, like this:

log.debug("Clicked edit for '\(account.name, privacy: .public)'.")

The WWDC23 session introducing this feature shows plenty of examples where the interpolated values show up in the log (in Xcode). I switched back to the old style, and the values DO show up for stdio output.

I can't find a reference to this being an issue in the Xcode 15 release notes, nor can I find a preference and/or schema value I can work with to get that private info to show up ... when I'm in Xcode. (I don't care about the Console app or log CLI apps -- those hide the data as expected.)

Anyone seeing this issue and/or know of a workaround?

Post not yet marked as solved Up vote post of zentrope Down vote post of zentrope
1.3k views

Replies

I had the same question and ended up discussing it here ( https://developer.apple.com/forums/thread/731121 ) and filing a report. Check the discussion to resolve the issue without the public modifier, if you'd like.

In short, string variables are private by default unless you add a plist entry for a specific logger subsystem and category or use other means. It's a bug, however, that the printout for private arguments in the Xcode console is blank. It should print <private> in-place of the argument.

  • Thanks! Reading....

Add a Comment

Are you sure that the Xcode console should be <private> for private arguments? They don't seem to be for the WWDC 2023 session on the subject, which matches the "unstructured" behavior in Xcode 14.

If we can't see the private strings and values in Xcode, then there's no point in logging at all. If we have to use the privacy: .public modifier to see them in the Xcode 15 console, then we're also exposing the data to the system log.