How can my iOS application read messages from the devices console log. I want to programmatically read through these log entries (like reading a file?), select some, and email them to support.
I'm aware of one iPhone application which lets you view the log. It's name is Console. However, I can't figure out what classes or APIs he used. One person suggested it was done using ASL functions, but I don't know what these are or where they are documented.
I'm also aware of several alternatives to using NSLog such as NSLogger and CocoaLumberJack, but we aren't ready to implement these at this time.
Thanks very much for any help!
Here's a Swift implementation if anyone's looking for one:
The older way people suggested work perfectly till iOS 9 but that will not work with iOS 10/XCode8.
There is a new way of logging introduces in iOS10/XCode8, Unified Logging and Activity Tracing.
https://developer.apple.com/reference/os/1891852-logging#1682426 https://developer.apple.com/videos/play/wwdc2016/721/
User this for logging:
https://github.com/SRGSSR/srglogger-ios
As of IOS 7, this method won't work any more. Apple removed access to ASL due to security reason.
This entry in the Cocoanetics blogs has sample code to access the system log on iOS using the ASL (Apple System Logger) API (man page):
Note that you need to poll ASL to read the latest messages. The code above will also fail when ran on the iPhone simulator, but works just fine on an actual device.
If you don't want to fight the C ASL API, have a look at this Objective-C wrapper called ASLogger.