OSLog output in Xcode console ignoring OSLogIntegerFormatting?!

In my Swift macOS app, I use OSLog logging via the line:

logger.log("••• channel \(channel, format: .octal(minDigits: 3))")

.. and the Xcode console shows:

••• channel 29

.. the formatting to octal and minDigits are ignored. I've searched high and low for why this is happening (another app with the same line results in correct Xcode console output).

The Console.app does show the correct output:

••• channel 035

Any suggestions regarding what I'm not understanding? Thanks.

Answered by RamsayCons in 795785022

Good call ..

I removed both IDEPreferLogStreaming and IDELogRedirectionPolicy and logging appears as it should.

A whisper of confusion remains because the culprit is IDEPreferLogStreaming. With only that set to YES the output formatting is defeated. Adding IDELogRedirectionPolicy restored correct formatting; removing both keeps formatting as it should be.

.. no env vars = good
.. both env vars = good
only IDEPreferLogStreaming = bad

Hi, Thanks for submitting this issue. Please file a feedback on Xcode, here. Also please include the FB number in this thread so it can be tracked more easily. In your report please include an xcresult bundle for a run that is effected by this. (Report Navigator > Select Run > Right Click Run > Show In Finder) Additionally please include Xcode version, macOS version, and optionally external device OS version if ran on a device.

FB: FB14340500

(While composing the report, the zip'd xcresult bundles from last night were deleted, by Xcode?, so I built/run the app again and enclosed the new one)

I was logging a lot of data very fast and found a suggestion, buried in the log, to use “IDELogRedirectionPolicy=oslogToStdio” to avoid potential loss. Using that environment setting restored the desired formatting!

"[guessing] .. I understand the “IDELogRedirectionPolicy” can influence how logging behaves (the 'privacy' for example) but could it be that very high rates of logging cause the logging system to save time by not doing formatting .. that kind of makes sense; the logged data is still correct, just not formatted?

I see "IDELogRedirectionPolicy" is mentioned in the Xcode 15 release notes.

I would recommend removing all env vars just to see if this is happening for you with the default settings, particularly env vars with these keys if there are any. IDEPreferLogStreaming, IDELogRedirectionPolicy, OS_ACTIVITY_DT_MODE and other env vars containing OS_ACTIVITY.

Note: I was not able to recreate this issue with Latest Beta Software using the default settings. (I am guessing there is something set)

Accepted Answer

Good call ..

I removed both IDEPreferLogStreaming and IDELogRedirectionPolicy and logging appears as it should.

A whisper of confusion remains because the culprit is IDEPreferLogStreaming. With only that set to YES the output formatting is defeated. Adding IDELogRedirectionPolicy restored correct formatting; removing both keeps formatting as it should be.

.. no env vars = good
.. both env vars = good
only IDEPreferLogStreaming = bad

OSLog output in Xcode console ignoring OSLogIntegerFormatting?!
 
 
Q