ios 如何从 iPhone 查看日志?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10335038/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 18:06:51  来源:igfitidea点击:

How to view logs from iPhone?

iphoneiosmacosios5nslog

提问by Firdous

I have place several NSLog() in my iOS application, is it possible to see all the logs later on my Mac that was generated when the app ran on iPhone handset even when iPhone was not connected with Mac. Thanks

我在我的 iOS 应用程序中放置了几个 NSLog(),是否可以在我的 Mac 上看到所有日志,这些日志是在 iPhone 手机上运行应用程序时生成的,即使 iPhone 没有与 Mac 连接。谢谢

采纳答案by Yusuf X

No. You can however redirect NSLog to a file, using something like this: http://blog.coriolis.ch/2009/01/09/redirect-nslog-to-a-file-on-the-iphone/

不。但是,您可以使用以下内容将 NSLog 重定向到文件:http: //blog.coriolis.ch/2009/01/09/redirect-nslog-to-a-file-on-the-iphone/

Then you can access the file via Xcode, or upload it with your app. File usage and privacy issues apply.

然后您可以通过 Xcode 访问该文件,或使用您的应用程序上传它。文件使用和隐私问题适用。

Keep in mind that NSLog is supposed to be turned off in published apps, so you may want to use a different logging app. A number of NSLog alternatives are available.

请记住,NSLog 应该在已发布的应用程序中关闭,因此您可能需要使用不同的日志记录应用程序。有许多 NSLog 替代品可用。

回答by verhage

You can view crash logs from your iPhone in the Organizer.

您可以从 iPhone 的管理器中查看崩溃日志。

If you want to view your own log statements, you could consider TestFlight ( http://testflightapp.com). They offer an SDK which includes features for remote logging.

如果您想查看自己的日志语句,可以考虑 TestFlight ( http://testflightapp.com)。他们提供了一个 SDK,其中包括远程日志记录功能。

回答by bontoJR

Unfortunately this is not possible. The only thing that you can get is a Crash Log. If you need a better logging system, I suggest to take a look to CocoaLumberHyman, a very powerful logging framework that gives you the opportunity to save log in files and, eventually, send them to a server. You also have many different levels like: log info, log error, log warning, etc...

不幸的是,这是不可能的。您唯一可以获得的是崩溃日志。如果你需要一个更好的日志系统,我建议你看看CocoaLumberHyman,一个非常强大的日志框架,让你有机会保存日志文件,并最终将它们发送到服务器。您还有许多不同的级别,例如:日志信息、日志错误、日志警告等...

回答by Jezen Thomas

I'm fairly certain that's not possible. The device needs to be connected to the Mac in order to run in Xcode's debug mode, and you need to be in debug mode to view the console, which contains your NSLogs.

我相当肯定这是不可能的。设备需要连接到 Mac 才能在 Xcode 的调试模式下运行,您需要在调试模式下查看控制台,其中包含您的 NSLogs。

回答by Manuel

There is a crash log for every crash that occurs on the phone, which is readable after connecting to your mac. These NSLog's don't appear in this log nor do they appear anywhere else in a (semi) permanent manner.

手机上发生的每次崩溃都有一个崩溃日志,连接到您的 mac 后可以读取该日志。这些 NSLog 不会出现在此日志中,也不会以(半)永久方式出现在其他任何地方。

回答by Templar

It's possible using custom macros and a custom class which will write each message in the documents directory in a file. If the file sharing is enabled in the app you can later download them in iTunes.

可以使用自定义宏和自定义类将文档目录中的每条消息写入文件。如果在应用程序中启用了文件共享,您可以稍后在 iTunes 中下载它们。

回答by Mahbub Morshed

Seeing the logs in mac might not be possible. But you can send the log to testflight using TFLog(). But you will need to distribute your app through testflightapp. And integrate the sdk. I think that is what you are looking for. try out - testflightapp.com

在 mac 中查看日志可能是不可能的。但是您可以使用 TFLog() 将日志发送到 testflight。但是您需要通过 testflightapp 分发您的应用程序。并集成sdk。我认为这就是你要找的。试用 - testflightapp.com