我已经在 iOS 应用程序中通过 OSLog 设置了日志记录,并且添加了一个按钮来使用 OSLogStore 导出日志:
extension OSLog {
private static let subsystem = Bundle.main.bundleIdentifier!
@available(iOS 15.0, *)
static func getLogs(inLast: TimeInterval) -> [OSLogEntryLog]? {
guard let store = try? OSLogStore(scope: .currentProcessIdentifier) else { return nil }
let startTime = store.position(timeIntervalSinceEnd: -inLast)
guard let entries = try? store.getEntries(at: startTime).compactMap({ $0 as? OSLogEntryLog }).filter({ $0.subsystem == subsystem }) else { return nil }
return entries
}
}
Run Code Online (Sandbox Code Playgroud)
这在本地测试时效果很好,即使在发布版本中也会导出所有日志。但是,当我们的团队通过 TestFlight 测试构建时,不会导出调试日志。有没有办法导出所有日志,包括调试日志?
Ann*_*rze -1
Claus J\xc3\xb8rgensen 的答案有效。人们确实可以将设置添加到 Info.plist,并且调试级别消息会显示在 iOS 上的 OSLogStore 中。通过阅读 Apple 的文档,我假设这些东西的配置只能在 macOS 中进行。
\n如果它对任何人有帮助:有关 Info.plist 的一些信息位于man 5 os_log:
\n\n应用程序特定的配置文件位于应用程序的 Info.plist 文件中的 OSLogPreferences 字典中。该字典中的键对应于子系统名称,其值是子系统字典。
\n
\n\n通常,系统仅将调试和信息消息存储在内存中,...
\n
和:
\n\n\n日志级别的严重性会影响系统记录信息的速度。调试日志的开销非常低,因为系统仅将它们存储在内存中。
\n
从在 iOS 上使用 OSLogStore 时所看到的情况来看,OSLogStore 似乎不包含调试消息。
\n\n| 归档时间: |
|
| 查看次数: |
1283 次 |
| 最近记录: |