Disabling Core Data CloudKit Logging

How do you stop the Core Data CloudKit sync logging from filling the Xcode console?

Core Data CloudKit Logging

If you’re using CloudKit to sync Core Data, or Swift Data, you’ll be familiar with the noise it creates in the Xcode console:

CoreData: CloudKit: CoreData+CloudKit: -[NSCloudKitMirroringDelegate
executeMirroringRequest:error:](969): <NSCloudKitMirroringDelegate:
0x600003d143c0>: Asked to execute request: <NSCloudKitMirroringExportRequest:
0x600002119680> FAA2E23B-D458-4527-BAF6-679945DB3934
CoreData: CloudKit: CoreData+CloudKit: -[NSCloudKitMirroringDelegate 
_enqueueRequest:]_block_invoke(1003): <NSCloudKitMirroringDelegate: 
0x600003d143c0>: enqueuing request: <NSCloudKitMirroringExportRequest: 
0x600002119680> FAA2E23B-D458-4527-BAF6-679945DB3934
...

Xcode 15 has ways to filter the log messages in the console but I’ve never found the CoreData+CloudKit debug messages to be useful and I don’t want to see them cluttering up the Xcode console.

Disabling CoreData Logging

Apple’s documentation on syncing a Core Data store with CloudKit suggests we can choose the level of detail that Core Data with CloudKit logs with a launch argument:

-com.apple.CoreData.CloudKitDebug 1

They suggest starting at 1 and increasing for more detail. I want less detail and setting that argument to 0 has no visible effect. I don’t remember where I first saw it but there’s another launch argument to turn off those verbose and unhelpful Core Data logs:

-com.apple.CoreData.Logging.stderr 0

That works for me! I still see errors, for example if I’m not logged into iCloud on the device or simulator but without the debug noise.

Xcode scheme launch arguments with Core Data stderr logging set to 0

For a reminder on how to add launch arguments to an Xcode scheme and other recommended launch arguments see Debugging Core Data.

Streaming Logs

The Apple documentation also includes a useful tip for streaming the Core Data and CloudKit logs from the terminal. For example (change “MyApp” to your App name):

log stream --info --debug --predicate 'process = "MyApp" and
(subsystem = "com.apple.coredata" or subsystem = "com.apple.cloudkit")'

Useful if you do want to check the logs without them filling the Xcode console.

See Also