What is the best practice to log errors/events in an iPhone application? I'm not talking about debugging, but after an app has been released. I mean, I'd like to collect errors/events logs when the app is running in released mode (not debug mode). (When needed I can ask the user to voluntarily send the file to my server for analysis.)
(Does NSLog have any effect if it is not running in debug? If so, where does it write to? And, how to clear any contents programatically?)
I posted an answer to a similar question over here: Including custom data into iOS crash dumps
NSLog should not be used for detailed logging in production apps, since it slows down your application. NSLog opens a connection to the system logger every single time it is being called and does that synchronously, so blocking the current thread.
Rather use CocoaLumberjack, which logs asynchronously, is very very fast and provides log level support out of the bugs which even can be changed at runtime with some additional efforts (see it's wiki pages). In addition it supports multiple output destinations, like files, console or Xcode console and more.
Another great logging library is NSLogger, which provides a Mac application to stream the log data via Bonjour. Both these libraries can be used together, meaning streaming log data from CocoaLumberjack to the NSLogger Mac app by using this connector: https://github.com/steipete/NSLogger-CocoaLumberjack-connector
I prefer to use http://www.flurry.com Or https://testflightapp.com
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With