When i try to get the console logs from device by connecting it to xcode, i only get last few hours logs. How do i get the console logs for atleast last 24 hours.
how to get console logs for the last 24 hours
There is no way to do this. iOS maintains a small in-memory buffer of log entries; it does not persist them to disk.
You can keep a record of all log entries using the Devices window in Xcode, but this only works if you keep the device attached via USB. That's helpful in some situations, but doesn't cover all cases.
If the relevant log entries are being created by your app, I recommend that you create your own app-specific logic to persist them to disk.
Finally, feel free to file enhancements requests for any features you'd like in this space. If you do, please post your bug number, just for the record.
Share and Enjoy
—
Quinn "The Eskimo!"
Apple Developer Relations, Developer Technical Support, Core OS/Hardware
let myEmail = "eskimo" + "1" + "@apple.com"
As Quinn said, iOS only maintaines a short buffer of log entries. You may want to look at a logging solution like CocoaLumberjack which optionally allows you to maintain app logs over many days.
- Tom
OS Log / Logger
- It is now possible using Apple's unified logging (OS Log / Logger)
- Refer: https://developer.apple.com/wwdc20/10168
Note:
- Make sure your device is connected to the Mac either (USB / network)
- Network would work only if
Connect via network
is checked
Terminal
Run the following command on the terminal:
sudo log collect --device-name yourdevicename --start '2022-12-01 13:15:00' --output mine.logarchive
Here your yourdevicename is your device's name
Open file
Double clicking the file should open in console