减少CoreData的调试输出?

eiv*_*dml 3 macos core-data ios swift

I'm working on a iOS/macOS project where I'm using CoreData. It works fine, but it outputs enormous amounts of debugging info to the Console. This makes the Console unusable, since my print statements are buried in all the CoreData related stuff.

I have a pretty simple CoreData setup with fetching of some data, so these are not errors, just general event logs it seems. I have the same results on other projects I have used CoreData.

Any way to reduce/remove this logging to the console?

Some sample data (all data here):

CoreData: warning: CoreData+CloudKit: -[NSCloudKitMirroringDelegate _

performExportWithRequest:]_block_invoke_2(946): Finished export: <PFCloudKitExporter: 0x2838bd840>
CoreData: CloudKit: CoreData+CloudKit: -[NSCloudKitMirroringDelegate _finishedRequest:withResult:](2102): Finished request: <NSCloudKitMirroringExportRequest: 0x2823bbb40> DC26CDEE-0AB6-42CD-81E5-996E7E7727F9 with result: <NSCloudKitMirroringResult: 0x282dfcfa0> success: 1 madeChanges: 0 error: (null)
CoreData: CloudKit: CoreData+CloudKit: -[NSCloudKitMirroringDelegate _scheduleAutomatedExportWithLabel:activity:completionHandler:]_block_invoke(2170): <NSCloudKitMirroringDelegate: 0x281ae4580> - Finished automatic export - AppActivationExport - with result: <NSCloudKitMirroringResult: 0x282dfcfa0> success: 1 madeChanges: 0 error: (null)
CoreData: warning: CoreData+CloudKit: -[NSCloudKitMirroringDelegate finishedAutomatedRequestWithResult:](2115): Finished request '<NSCloudKitMirroringExportRequest: 0x2823bbb40> DC26CDEE-0AB6-42CD-81E5-996E7E7727F9' with result: <NSCloudKitMirroringResult: 0x282dfcfa0> success: 1 madeChanges: 0 error: (null)
CoreData: CloudKit: CoreData+CloudKit: -[NSCloudKitMirroringDelegate checkAndExecuteNextRequest](2073): <NSCloudKitMirroringDelegate: 0x281ae4580>: Checking for pending requests.
CoreData: CloudKit: CoreData+CloudKit: -[NSCloudKitMirroringDelegate checkAndExecuteNextRequest]_block_invoke(2088): <NSCloudKitMirroringDelegate: 0x281ae4580>: No more requests to execute.
CoreData: CloudKit: CoreData+CloudKit: -[NSCloudKitMirroringDelegate _scheduleAutomatedImportWithLabel:activity:completionHandler:](2140): <NSCloudKitMirroringDelegate: 0x281ae4580> - Beginning automated import - ImportActivity - in response to activity:
<CKSchedulerActivity: 0x280ec8f00; additionalXPCActivityCriteria={
    Priority = Utility;
}
Run Code Online (Sandbox Code Playgroud)

AD *_*ess 46

尝试将这些添加为启动参数,看看它是否有帮助

-com.apple.CoreData.SQLDebug 0
-com.apple.CoreData.Logging.stderr 0               
-com.apple.CoreData.ConcurrencyDebug 0
-com.apple.CoreData.MigrationDebug 0
Run Code Online (Sandbox Code Playgroud)

EDIT1:我在 Apple 文档中找到了这个:选择 Product > Scheme > Edit Scheme。选择一个操作,例如 Run,然后选择 Arguments 选项卡。将带有调试级别值的 com.apple.CoreData.CloudKitDebug 用户默认设置作为参数传递给应用程序。 像这样

 -com.apple.CoreData.CloudKitDebug 0
Run Code Online (Sandbox Code Playgroud)

添加最后一个作为启动参数,您应该实现您想要的。

链接到 AppleDocs 检查名为Debug Errors in Core Data with CloudKit 的部分

  • 我曾尝试过 Apple 文档中的 .CloudKitDebug,但没有成功,但使用所有 5 个参数最终成功了 (4认同)
  • 谢谢,必须从 CloudKit 和 CoreData 的大量输出中搜索我真正需要记录的内容,这让我发疯 (2认同)
  • 这对于 iOS 来说效果很好,但由于某些原因,运行 watchOS 应用程序时日志会不断显示(启动参数传递给手表应用程序)。 (2认同)

J. *_*Doe 8

在 Xcode 中执行以下步骤:

  1. 产品
  2. 方案
  3. 编辑方案...
  4. 选择左侧构建应用程序的方式(我猜是运行)

我想您会-com.apple.CoreData.SQLDebug在“发布时传递的参数”中看到。如果您看到该内容,请将其关闭。如果您没有看到它,请添加:

-com.apple.CoreData.SQLDebug 1
Run Code Online (Sandbox Code Playgroud)

数值和描述:

  1. SQL 语句、行数和执行时间
  2. 绑定值和 NSSQLiteStatement 的截断版本,未列出托管对象的完整列表。
  3. 为查询返回的托管对象列表。这些对象尚未故障进入内存,因此仅输出托管对象 ID。
  4. SQLite 解释查询计划

来自http://blog.raymccrae.scot/2017/12/core-data-sqldebug-log-levels.html


nou*_*tzi 6

我有同样的问题。
这将禁用CoreData调试输出:
在“启动时传递的参数”中:
-com.apple.CoreData.Logging.stderr 0
对我有用。

  • 接受的答案对我不起作用,但这确实有效。谢谢! (3认同)