I've set up logging through OSLog in my iOS App, and I've added a button to export logs with 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
}
}
This works fine when testing locally, all logs are exported even in release builds. However, when our team is testing builds through TestFlight, debug logs are not exported. Is there a way to export all logs including debug logs?
Claus Jørgensen's answer works. One can indeed add the settings to an Info.plist and the debug level messages appear in OSLogStore on iOS. From reading Apple's documentation, I was assuming that the configuration of these things is only possible in macOS.
In case it helps anybody: Some information about the Info.plist is in
man 5 os_log:I suspect, that debug level messages are not accessible from the OSLogStore - at least currently with iOS 17 / Xcode 15. From Apple's documentation ([Generating Log Messages from Your Code][1]):and:
From what one can see when playing with OSLogStore on iOS, it looks like OSLogStore just does not include debug messages.