Logger messages not showing in XCode console

XCode version 13.2.1

I enabled os_log messages using the following code:

   let myLog = OSLog(subsystem: "testing", category: "exploring")

  override func viewDidLoad() {
    os_log("LOGGING TEST BLAH BLAH", log: myLog)
    print("Starting ViewDidLoad")
    super.viewDidLoad()
    os_log("LOGGING TEST BLAH BLAH", log: myLog)'
...

However, I do not see anything on the XCode console - just the print ("Starting ViewDidLoad").

Is there a setting in XCode to echo messages from the logger that needs to be turned on?

I understand that Logger is the preferred method now instead of os_log, but both should echo the log messages on XCode debug console from what I can tell..

Thanks!

Note - I ran the same code on my iMac desktop with Xcode 12, and I got the expected output. Other logger messages (from Firebase/Analytics) are also showing up there. Clearly some output setting is different between the two...

Found the issue I had set the following environment variable in my scheme: OS_ACTIVITY_MODE=disable. Removing this environment fixed it. Don't recall why exactly this variable had been set, so recording it here for reference.

Don't recall why exactly this variable had been set

Historically there was a problem where Xcode’s console would display all your process’s log output, which meant that the log entries you cared about were drowned out by log entries coming from system frameworsk. The workaround was to set OS_ACTIVITY_MODE to disable. Nowadays this isn’t necessary because Xcode’s console only shows you log output from the main executable.

Share and Enjoy

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

@eskimo I am using Logger (OSLog) and I don't want debug messages from frameworks like mentioned below. What should I do to achieve that?

When I use CoreData / CloudKit especially NSPersistentCloudKitContainer I do see a lot of debug messages such as the ones below:

CoreData: debug: CoreData+CloudKit: -[PFCloudKitOptionsValidator validateOptions:andStoreOptions:error:](36): Validating options: <NSCloudKitMirroringDelegateOptions: 0x600002804090> containerIdentifier:<my bundle id> databaseScope:Private ckAssetThresholdBytes:<null> operationMemoryThresholdBytes:<null> useEncryptedStorage:NO useDeviceToDeviceEncryption:NO automaticallyDownloadFileBackedFutures:NO automaticallyScheduleImportAndExportOperations:YES skipCloudKitSetup:NO preserveLegacyRecordMetadataBehavior:NO useDaemon:YES apsConnectionMachServiceName:<null> containerProvider:<PFCloudKitContainerProvider: 0x600001800260> storeMonitorProvider:<PFCloudKitStoreMonitorProvider: 0x600001800320> metricsClient:<PFCloudKitMetricsClient: 0x600001800390> metadataPurger:<PFCloudKitMetadataPurger: 0x6000018003a0> scheduler:<null> notificationListener:<null> containerOptions:<null> defaultOperationConfiguration:<null> progressProvider:<NSPersistentCloudKitContainer: 0x600000f0d000> test_useLegacySavePolicy:YES archivingUtilities:<PFCloudKitArchivingUtilities: 0x6000018003b0> bypassSchedulerActivityForInitialImport:NO
storeOptions: {
    NSInferMappingModelAutomaticallyOption = 1;
    NSMigratePersistentStoresAutomaticallyOption = 1;
    NSPersistentCloudKitContainerOptionsKey = "<NSPersistentCloudKitContainerOptions: 0x60000140ac70>";
    NSPersistentHistoryTrackingKey = 1;
    NSPersistentStoreMirroringOptionsKey =     {
        NSPersistentStoreMirroringDelegateOptionKey = "<NSCloudKitMirroringDelegate: 0x60000230c380>";
    };
    NSPersistentStoreRemoteChangeNotificationOptionKey = 1;
}

I am using Logger (OSLog) and I don't want debug messages from frameworks

Your best option is to ignore the Xcode console pane and instead monitor your log messages using the Console app. This supports fine-grained filtering.

For this and other system log tips, see Your Friend the System Log.

Also, please do file an enhancement request against Xcode for better log filtering.

Share and Enjoy

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

@eskimo

Thanks a lot for the prompt reply, you are right we can filter by subsystem which is great.

Upon further investigation I realised these aren't debug messages that got printed, they were errors (not sure why though).

When I set the launch arguments as com.apple.CoreData.Logging.stderr 0 (under Scheme > Run > Arguments) I don't get these errors anymore.

The only question remaining is why are these errors thrown, I even tried with Xcode > New Project > Checking CloudKit and CoreData checkboxes, even on the new project with generated code these errors are thrown.

Tested on device with iCloud turned on, syncing is fine but not sure if I am missing something or this is a internal error within the framework.

FB FB11794798 - Feedback contains sample project

The only question remaining is why are these errors thrown

That seems like a question for folks who have expertise is those technologies. I recommend you start a new thread with the Core Data and CloudKit tags.

Share and Enjoy

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

Thanks a lot will post with CoreData and CloudKit tags

message: Logging Error: Failed to initialize logging system. Log messages may be missing. If this issue persists, try setting IDEPreferLogStreaming=YES in the active scheme actions environment variables. Xcode: Version 15.3 (15E204a) macOS Sonoma Version 14.4.1 (23E224)

Logger messages not showing in XCode console
 
 
Q