Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the best practice to log errors/events in an iPhone application? [closed]

Tags:

ios

iphone

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?)

like image 740
ikevin8me Avatar asked Sep 29 '12 22:09

ikevin8me


Video Answer


2 Answers

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

like image 172
Kerni Avatar answered Jan 03 '23 14:01

Kerni


I prefer to use http://www.flurry.com Or https://testflightapp.com

like image 26
Kassem Avatar answered Jan 03 '23 14:01

Kassem