iOS - 如何在手机上的 ssh 会话中查看 NSLog 和 printf 输出? [英] iOS - How to view NSLog and printf output in ssh session on phone?
问题描述
我有一个简单的 iPhone 应用程序,它使用一个 NSLog
和几个 printf
语句.该应用程序是我创建的一个简单的测试应用程序,用于测试 iPhone (3GS) 上的串行通信.显然,我无法使用 iOS 模拟器测试串行通信,因此在我单击 Xcode 中的 Run
后,我将设备从计算机上拔下.我从 Cydia 安装了 syslogd,并且 tail/var/log/syslog
允许我监视某些日志消息.
I have a simple iPhone App that uses an NSLog
and several printf
statements. The app is a simple test app that I created to test serial communication on the iPhone (3GS). Obviously I can not test serial com with the iOS Simulator, so I have my device unplugged from the computer after I click Run
from within Xcode. I installed syslogd from Cydia, and tail /var/log/syslog
allows me to monitor certain log messages.
但是,当我打开我的应用程序并到达代码的 NSLog
部分时,我没有看到消息出现在 /var/log/syslog
中,我也没有看到在应用程序的 syslog
文件中看不到 printf
语句输出.
However when I open my app and it reaches the NSLog
portion of the code I don't see the message appear in /var/log/syslog
I also don't see the printf
statements output in the syslog
file for the app.
iPhone 本身是否存在包含这些语句输出的文件,或者我是否需要指定我的应用程序以输出到 /var/log/syslog
?
Is there a file that exists on the iPhone itself that contains the output from these statements, or do I need to specify my app to output to /var/log/syslog
?
如果手机上存在另一个包含日志消息内容的文件,我很满意.基本上,我希望能够在 sshed
进入手机时看到日志消息的内容,以便我可以看到发生了什么.显然在 Xcode 中使用控制台输出不是一个选项,因为手机没有连接到计算机.
I am content with opening another file if it exists on the phone that contains the contents of the log messages. Basically I want to be able to see the contents of the log messages while I am sshed
into the phone so I can see what is going on. And obviously using the Console output in Xcode is not an option because the phone isn't connected to the computer.
推荐答案
你在使用 tail/var/log/syslog
吗?它只显示日志的最后 15 行.也许尝试使用 tail -f/var/log/syslog
.我刚刚测试了它,它记录了我的简单 NSLog(@"LOL");
就好了.我能够通过 ssh 和所有内容看到它.
Are you using tail /var/log/syslog
? It only shows the last 15 lines of the log. Maybe try using tail -f /var/log/syslog
. I just tested that and it logged my my simple NSLog(@"LOL");
just fine. I was able to see it via ssh and everything.
这篇关于iOS - 如何在手机上的 ssh 会话中查看 NSLog 和 printf 输出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!