iOS(iPhone、iPad、iPodTouch)查看实时控制台日志终端
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7277804/
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
iOS (iPhone, iPad, iPodTouch) view real-time console log terminal
提问by Arunabh Das
Is there a way to view the real-time console log to view NSLog and other debug messages in a real-time manner, such as adb logcat?
有没有办法实时查看控制台日志,实时查看NSLog等调试信息,比如adb logcat?
回答by Marián ?erny
The solution documented by Apple in Technical Q&A QA1747 Debugging Deployed iOS Appsfor Xcode 6 is:
Apple 在 Technical Q&A QA1747 Debugging Deployed iOS Appsfor Xcode 6 中记录的解决方案是:
- Choose Window -> Devices from the Xcode menu.
- Choose the device in the left column.
- Click the up-triangle at the bottom left of the right hand panel to show the device console.
- 从 Xcode 菜单中选择 Window -> Devices。
- 在左栏中选择设备。
- 单击右侧面板左下角的上三角形以显示设备控制台。
回答by Ben Clayton
EDIT: Please use @cbowns solution - deviceconsole is compatible with iOS9 and much easier to use.
编辑:请使用@cbowns 解决方案 - deviceconsole 与 iOS9 兼容并且更易于使用。
This is a open-source program that displays the iDevice's system log in Terminal (in a manner similar to tail -F). No jailbreak is required, and the output is fully grep'able so you can filter to see output from your program only. What's particularly good about this solution is you can view the log whether or not the app was launched in debug mode from XCode.
这是一个开源程序,它在终端中显示 iDevice 的系统日志(以类似于 tail -F 的方式)。不需要越狱,并且输出是完全可以grep的,因此您可以过滤以仅查看程序的输出。此解决方案的特别之处在于,无论应用程序是否在调试模式下从 XCode 启动,您都可以查看日志。
Here's how:
就是这样:
Grab the libimobiledevice binary for Mac OS X from my github account at https://github.com/benvium/libimobiledevice-macosx/zipball/master
从https://github.com/benvium/libimobiledevice-macosx/zipball/master 的github 帐户中获取适用于 Mac OS X 的 libimobiledevice 二进制文件
Follow the install instructions here: https://github.com/benvium/libimobiledevice-macosx/blob/master/README.md
按照此处的安装说明进行操作:https: //github.com/benvium/libimobiledevice-macosx/blob/master/README.md
Connect your device, open up Terminal.app and type:
连接您的设备,打开 Terminal.app 并输入:
idevicesyslog
Up pops a real-time display of the device's system log.
向上弹出设备系统日志的实时显示。
With it being a console app, you can filter the log using unix commands, such as grep
由于它是一个控制台应用程序,您可以使用 unix 命令过滤日志,例如 grep
For instance, see all log messages from a particular app:
例如,查看来自特定应用程序的所有日志消息:
idevicesyslog | grep myappname
Taken from my blog at http://pervasivecode.blogspot.co.uk/2012/06/view-log-output-of-any-app-on-iphone-or.html
摘自我的博客http://pervasivecode.blogspot.co.uk/2012/06/view-log-output-of-any-app-on-iphone-or.html
回答by cbowns
Two options:
两种选择:
libimobiledeviceis installable via homebrewand works great. Its idevicesyslog
tool works similarly to deviceconsole
(below), and it supports wirelessly viewing your device's syslog (!)
libimobiledevice可以通过自制软件安装并且运行良好。它的idevicesyslog
工具与deviceconsole
(如下)类似,它支持无线查看设备的系统日志(!)
I've written more about that on Tumblrtl;dr:
brew install libimobiledevice
idevice_id --list // list available device UDIDs
idevicesyslog -u <device udid>
with the device connected via USB or available on the local wireless network.
设备通过 USB 连接或在本地无线网络上可用。
From 2013: deviceconsolefrom rpetrich is a much less wacked-out solution than ideviceconsole above. My fork of itbuilds and runs in Xcode 5 out of the box, and the Build action will install the binary to /usr/local/bin
for ease of use.
从 2013 年开始:rpetrich 的deviceconsole是一个比上面的 ideviceconsole 少得多的解决方案。我的fork在 Xcode 5 中开箱即用地构建和运行,构建操作将安装二进制文件以/usr/local/bin
方便使用。
As an additional helpful bit of info, I use it in the following style which makes it easy to find the device I want in my shell history and removes unnecessary >
lines that deviceconsole
prints out.
作为额外有用的信息,我以以下样式使用它,这样可以轻松地在我的 shell 历史记录中找到我想要的设备,并删除打印出来的不必要的>
行deviceconsole
。
deviceconsole -d -u <device UDID> | uniq -u && echo "<device name>"
回答by einsA
Just open the Application Console.app
on mac osX.
只需Console.app
在 mac osX 上打开应用程序。
You can find it under Applications
> Utilities
> Console
.
您可以在Applications
> Utilities
>下找到它Console
。
On the left side of the application all your connected devices are listed.
在应用程序的左侧列出了所有连接的设备。
回答by Peter Gluck
Try the freeware iOS Console. Just download, launch, connect your device -- et voila!
试用免费软件iOS 控制台。只需下载、启动、连接您的设备——等等!
回答by BryanH
This might be what you're looking for: Xcode Organizer
这可能就是您要找的: Xcode Organizer
回答by kitchen
device > terminal output is on iPhone configuration app
设备 > 终端输出在 iPhone 配置应用程序上
回答by fbernardo
You have three options:
您有三个选择:
- Xcode Organizer
- Jailbroken device with syslogd + openSSH
- Use dup2 to redirect all STDERR and STDOUT to a file and then "tail -f" that file (this last one is more a simulator thing, since you are stuck with the same problem of tailing a file on the device).
- Xcode 管理器
- 带有 syslogd + openSSH 的越狱设备
- 使用 dup2 将所有 STDERR 和 STDOUT 重定向到一个文件,然后“tail -f”该文件(最后一个更像是一个模拟器,因为您遇到了在设备上拖尾文件的相同问题)。
So, to get the 2o one you just need to install syslogd and OpenSSH from Cydia, restart required after to get syslogd going; now just open a ssh session to your device (via terminal or putty on windows), and type "tail -f /var/log/syslog". And there you go, wireless real time system log.
因此,要获得 2o 版本,您只需要从 Cydia 安装 syslogd 和 OpenSSH,然后重新启动即可使 syslogd 运行;现在只需打开一个到您设备的 ssh 会话(通过终端或 Windows 上的腻子),然后输入“tail -f /var/log/syslog”。好了,无线实时系统日志。
If you would like to try the 3o just search for "dup2" online, it's a system call.
如果您想尝试 3o,只需在线搜索“dup2”,这是一个系统调用。
回答by nick
To view your iOS device's console in Safari on your Mac (Mac only apparently):
要在 Mac 上的 Safari 中查看 iOS 设备的控制台(显然仅适用于 Mac):
- On your iOS device, go to Settings > Safari > Advanced and switch on Web Inspector
- On your iOS device, load your web page in Safari
- Connect your device directly to your Mac
- On your Mac, if you've not already got Safari's Developer menu activated, go to Preferences > Advanced, and select "Show Develop menu in menu bar"
- On your Mac, go to Develop > [your iOS device name] > [your web page]
- 在您的 iOS 设备上,转到设置 > Safari > 高级并打开 Web Inspector
- 在您的 iOS 设备上,在 Safari 中加载您的网页
- 将您的设备直接连接到 Mac
- 在 Mac 上,如果您尚未激活 Safari 的开发者菜单,请转到首选项 > 高级,然后选择“在菜单栏中显示开发菜单”
- 在 Mac 上,转到开发 > [您的 iOS 设备名称] > [您的网页]
Safari's Inspector will appear showing a console for your iOS device.
Safari 的检查器将出现,显示 iOS 设备的控制台。
回答by Jonathan.Brink
As an alternative, you can use an on-screenlogging tool like ticker-logto view logs without having (convenient) access to the console.
作为替代方案,您可以使用像ticker-log这样的屏幕日志工具来查看日志,而无需(方便)访问控制台。