Search code examples
iphoneobjective-ciosnslog

Should I remove NSLogs when releasing my App


Is it advisable to do any NSLogging in a shipping app? I know that I should not in heavily used loops. Or not log too verbosely. But I am not sure if it is a good practice to do so.

Removing all the NSLogs prior to a release does not seem like a good practice too.


Solution

  • I think it is a good practice to not spam the user's device log.

    For this, I have a macro, DebugLog, that is only active for debugging builds:

    #ifdef DEBUG
    #define DebugLog(fmt, ...) NSLog(fmt, __VA_ARGS__)
    #else
    #define DebugLog(fmt, ...)
    #endif
    

    For all log messages that are interesting to me for development, I use DebugLog. For all error messages that should be logged I use unconditional NSLog. This way the distribution builds don't clutter the user's console log. Only important messages get logged.