NSLog() 是否存储在设备(iPhone 等)上?如果是的话,在哪里?
是否应该在 iTunes 的最终应用程序中删除所有 NSLog() 调用?
在我的 iOS 应用程序中,我有很多 NSLog() 用于调试。 我应该在上传到 iTunes 之前有条件地对它们进行编码吗?
这是一个适用于以下设备的应用程序:iPhone、iPod、iPad
谢谢。
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 uploading to iTunes?
This is for an app for: iPhone, iPod, iPad
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
我将回答标题中OP关于日志存储在设备上的位置的问题。 NSLog() 使用 ASL(Apple 系统记录器)。通过编程方式,您只能读取最后 256 个条目(例如,Xcode 在管理器中显示的内容)。
但是,如果您想访问完整的文件,它们存储在:
当您查看该目录时(注意:设备必须越狱),您会发现一长串 *.asl 文件。
我找到了一个解析这些文件的工具,但我还没有尝试过,所以 YMMV:
在 iOS 和 OSX 上解析 Apple 系统日志 (ASL) 文件以获取乐趣和证据(以及一个可以为您完成此操作的 Python 脚本)
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:
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)
您不必将它们全部删除;事实上,如果您的应用程序在用户的手机上崩溃并且您希望他们向您发送崩溃日志,那么它们可能会很有用。当用户同步他/她的手机时,崩溃日志位于文件夹中。
如果您有 NSLog(),您可能会像调试时一样获得有用的信息。正如其他人指出的那样,不要做得太过分,但它们最终可能会很有用。
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
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.是的,我们应该在上传到 iTunes 之前删除所有 NSLog() 调用。这样做主要是为了更好的性能。
即使你不删除它们,也没有问题。它将被批准。但是如果你有很多 NSLog() ,那将会是这样。影响性能。
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.
尝试将其用于您的 NSLog:
Try using this for your NSLogs:
不是全部。您应该保留错误日志。如果出现任何错误或崩溃,这将很容易定位。
也可以使用 Organizer 查看 NSLog 消息。
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.
如果 NSLogs 针对 DEBUG 模式添加,则无需删除它们。因此,即使您的应用程序崩溃并且包含用户个人数据,它也会被 ios 删除。所以不用担心用户数据和NSLog。请参阅https://developer.apple.com/library/ios/documentation/IDEs/Conceptual/AppDistributionGuide/AnalyzingCrashReports/AnalyzingCrashReports.html
不过,如果您愿意,您可以在应用程序中使用此 PJiOSAppConsole 。它只会在您的应用程序中保留日志。您可以在运行时使用它,方法是在 #ifdef 中添加代码片段,然后在您想要上线时将其删除。易于集成和使用。
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.