I understand that in iOS 15 and macOS Monterey, I can easily access the log system to get log entries for my app like this:
let store = try OSLogStore(scope: .currentProcessIdentifier)
I can then query store
for the log entries.
However, as it says right in the name, the store is only for current process, i.e current run of my app. When I try to get entries, I only get entries from the current run, even if I specify an earlier time like this:
guard let positionDate = Calendar.current.date(byAdding: .day, value: -7, to: Date()) else { return }
let position = store.position(date: positionDate)
let predicate = NSPredicate(format: "subsystem == 'com.exampl.emyAppSubsystem'")
let entries = try store.getEntries(with: [], at: position, matching: predicate)
for entry in entries {
print("Entry: \(entry.date) \(entry.composedMessage)")
}
Is there any way to access log entries for earlier runs of my app, e.g from days or weeks ago? Either on macOS or iOS?