iOS如何实时查看App运行日志


Linux下管理挂载IOS设备——libimobiledevice
https://www.jianshu.com/p/6423610d3293
https://www.aliyun.com/jiaocheng/147533.html?spm=5176.100033.2.7.a78d31adB9PthN&accounttraceid=355ae963-f6db-4e9c-9204-d1ff78e088a5
#####gitlib下载包--编译安装
git clone https://github.com/libimobiledevice/libplist.git
git clone https://github.com/libimobiledevice/usbmuxd.git
git clone https://github.com/libimobiledevice/libusbmuxd.git
git clone https://github.com/libimobiledevice/ideviceinstaller.git
git clone https://github.com/libimobiledevice/ifuse.git
git clone https://github.com/libimobiledevice/libirecovery.git
git clone https://github.com/libimobiledevice/libideviceactivation.git


./configure
make && make install
##创建挂接目录
mkdir -p /media/iphone
ifuse /media/iphone
idevicepair pair
idevice_id --list
##实时查看日志
idevicesyslog|grep com.bxd.help

libimobiledevice 查看应用日志

iOS实时查看App运行日志

前言:

本文讨论如何实时查看输出在console控制台的日志。


一、Xcode

版本号:9.4.1

通过Window->Devices and Simulators,打开Devices and Simulators界面,选择我们的手机,点击view device logs能看到手机中运行的进程输出的日志。如图:
 
image.png
 
image.png

二、libimobiledevice

安装libimobiledevice很简单,在命令行输入:

brew install --HEAD libimobiledevice 
注意,需要加上 –HEAD 选项,如果不加,安装是老版本,不支持iOS10的手机,所以安装时,需要加上 –HEAD 选项

1、使用idevicesyslog

在命令行输入:idevicesyslog
就可以在屏幕上看见手机上所有的日志了。
 
log.png

2、查看我们想要的日志

1)将设备日志重定向到文件

idevicesyslog >> iphone.log &
该命令是将日志导入到iphone.log这个文件,并且是在后台执行。

2)用tail -f和grep查看log

tail -f iphone.log
tail -f iphone.log | grep 'QQ' # 查看包含QQ的行
如下图:
 
QQ.png

三、控制台

在用过各种办法查看App日志后,还是觉得苹果系统自带的工具用起来最方便,不用安装,不用命令行,傻瓜式操作,非常方便。

连上手机,在LaunchPad其他文件中打开控制台应用,或者搜索Console.app打开控制台应用,可以看到左侧一栏中有我们的手机设备,选择就可以,如图:
 
控制台.png

右侧输出的日志不仅有我们自己的App还有其他进程的日志,怎么过滤?非常简单,选中一条我们的日志,在进程名字上右键,选择显示进程名,然后就只会显示我们App的日志。如果显示的列名中没有进程名,我们可以在其他列名上右键,在弹出的菜单中勾选上进程就可以了。如图显示WeChat打印出的日志:
 
WeChat1.png
 
WeChat2.png

猜你喜欢

转载自www.cnblogs.com/zgq123456/p/10222094.html