is NSLog() stored on the device (iPhone etc)? If so, where?

前端 未结 6 736
旧时难觅i
旧时难觅i 2020-12-16 20:18

Should all NSLog() calls be deleted in the final app for iTunes?

In my iOS app, I\'ve got lots of NSLog() for debug. Should I conditionally code them out before uplo

相关标签:
6条回答
  • 2020-12-16 20:51

    Yes, We should remove all the NSLog() calls before uploading to iTunes. That is done mainly for better performance.

    Even if u dont remove them, no problem. It will be approved. But if u have lot NSLog() s, the that will def. affect the performance.

    0 讨论(0)
  • 2020-12-16 20:52

    Try using this for your NSLogs:

    #define DEBUG
    
    #ifdef DEBUG
     NSLog(@"Your tests outputs");
    #endif
    
    0 讨论(0)
  • 2020-12-16 20:52

    You dont need to remove NSLogs if they added against DEBUG mode. So even if your app crashes and if it contains user personal data, it will be removed by ios. So do not worry about user data and NSLog. Refer https://developer.apple.com/library/ios/documentation/IDEs/Conceptual/AppDistributionGuide/AnalyzingCrashReports/AnalyzingCrashReports.html Still if you want you can use this PJiOSAppConsole in your application. It will keep logs in your application only. You can use it at runtime by adding snippet in #ifdef then remove whenever you want to go to live. Easy to integrate and use.

    0 讨论(0)
  • 2020-12-16 20:54

    Not all. You should keep the error logs. That will make it easy to locate if there is any error or crash. Its possible to see NSLog messages using Organizer too.

    0 讨论(0)
  • 2020-12-16 21:00

    You don't have to remove all of them; in fact, they can be useful if your app crashes on a user's phone and you want them to send you a crash log. When a user syncs his/her phone, the crash log is located in the folder

    ~/Library/Logs/CrashReporter/MobileDevice/<DEVICE_NAME>
    

    If you have NSLog()s you may gain useful information just as you would when debugging. As the others pointed out, don't overdo it, but it they could end up being useful.

    0 讨论(0)
  • 2020-12-16 21:08

    I'll answer the OP's question in the title about where the logs are stored on the device. NSLog() uses the ASL (Apple System Logger). Programmatically, you can only read the last 256 entries (which is what Xcode shows in the Organizer, for example).

    However, if you want to access the full files, they are stored in:

    /private/var/log/DiagnosticMessages
    

    When you look into that directory (note: device must be Jailbroken), you'll find a long list of *.asl files.

    I found a tool to parse those files, but I haven't tried it yet, so YMMV:

    Parsing Apple System Log (ASL) files on iOS and OSX for Fun and Evidence (and a Python script to do it for you)

    0 讨论(0)
提交回复
热议问题