I am doing a bunch of logging when I’m testing my application which is useful for getting information about variable state and such.
However I have read that you should use logging sparsely in production code (because it can potentially slow down your application). But my question is now: if my app is in production and people are using it, whenever a crash (god forbid) occurs, how will I be able to interpret the crash information if I have removed the logging statements? Then I suppose I will only have a stacktrace for me to interpret?
Does this mean I should leave logging in production code only WHERE it’s really essential for me to interpret what has happened?
Also how will the logging statements relate to the crash reports? Will they be combined? I’m thinking of using Flurry as analytics and crash reports…
You most definitely should include lots of logging in your released app. As you suspect, it can help you immensely when debugging, and it can even help your power users self-debug if you make sure your log messages are well-worded, reasonably self-explanatory and include all the relevant details.
There are many aspects to a good logging system. There’s a few common patterns that are often good to follow (though on iOS specifically some apply more-so than others):
You can get a lot of these features from pre-built logging systems, e.g. CocoaLumberjack and NSLogger (or both). No doubt there’s others.