iOS安全–实时查看模拟器的日志输出
2016-07-08 15:59
411 查看
最近在模拟器上面测试SDK,想看看模拟器断开xcode调试的日志输出,发现Xcode-Window-Devices里面并不能看到。
把日志重定向输出到log文件,便可以看到实时的log日志。
重定向日志输出代码:
然后在AppDelegate里面添加这个方法。
运行Xcode,得到document的目录,然后定位到该目录下面。
使用tail –f console.log实时查看。也可以使用tail –f console.log | grep “xxx”,进行过滤。
Log打印:
NSLog(@”this is my log”);
fprintf(stderr,”%s\n”,”this is my log”);
本文链接:http://www.blogfshare.com/redirect-console-log.html
把日志重定向输出到log文件,便可以看到实时的log日志。
重定向日志输出代码:
1 2 3 4 5 6 7 8 9 10 | -(void)redirectConsoleLog{ #ifdef DEBUG NSString *documentDir = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)[0]; NSLog(@"documentPath : %@",documentDir); //重定向NSLog NSString* logPath = [documentDir stringByAppendingPathComponent:@"console.log"]; freopen([logPath fileSystemRepresentation], "a+", stderr); #endif } |
然后在AppDelegate里面添加这个方法。
1 2 3 4 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { [self redirectConsoleLog]; } |
运行Xcode,得到document的目录,然后定位到该目录下面。
1 2 3 | documentPath : /Users/Monkey/Library/Developer/CoreSimulator/Devices/EC652E7F-BEAD-4153-9F56-7DC025D4050C/data/Containers/Data/Application/3741A5B7-DF67-4872-B0F2-4E6125C27E82/Documents cd /Users/Monkey/Library/Developer/CoreSimulator/Devices/EC652E7F-BEAD-4153-9F56-7DC025D4050C/data/Containers/Data/Application/3741A5B7-DF67-4872-B0F2-4E6125C27E82/Documents |
使用tail –f console.log实时查看。也可以使用tail –f console.log | grep “xxx”,进行过滤。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | cd /Users/Monkey/Library/Developer/CoreSimulator/Devices/EC652E7F-BEAD-4153-9F56-7DC025D4050C/data/Containers/Data/Application/3741A5B7-DF67-4872-B0F2-4E6125C27E82/Documents tail -f console.log 2016-03-11 11:20:43.430 BugrptSDKDemo[33376:6921912] <WORKFLOW>: sdk catch a exception 2016-03-11 11:20:43.922 BugrptSDKDemo[33376:6921912] <Info> Bugrpt: catch a fatal signal:6 [6,0,0] 2016-03-11 11:20:43.922 BugrptSDKDemo[33376:6921912] <Debug> Bugrpt: crash count is: 1 2016-03-11 11:20:43.922 BugrptSDKDemo[33376:6921912] <Debug> Bugrpt: CrashData is sessionEvent:( "sdk[1.1.2] handle signal:6 info(6,0,0)" ) crashTime:1457666443431 handler:Signal Handler type:NSRangeException(SIGABRT) error:*** -[__NSArrayI objectAtIndex:]: index 3 beyond bounds [0 .. 2] address:0x108e1a0ae crashThread:1803 lastExceptionInfo: name:(null) arch:(null) uuid:(null) addr:(null) bininfos:(null) crashStackNames:(null) |
NSLog(@”this is my log”);
fprintf(stderr,”%s\n”,”this is my log”);
本文链接:http://www.blogfshare.com/redirect-console-log.html
相关文章推荐
- 峰回路转,Firefox 浏览器即将重返 iOS 平台
- 峰回路转,Firefox 浏览器即将重返 iOS 平台
- 不可修补的 iOS 漏洞可能导致 iPhone 4s 到 iPhone X 永久越狱
- iOS 12.4 系统遭黑客破解,漏洞危及数百万用户
- 每日安全资讯:NSO,一家专业入侵 iPhone 的神秘公司
- [转][源代码]Comex公布JailbreakMe 3.0源代码
- 讲解iOS开发中基本的定位功能实现
- iOS中定位当前位置坐标及转换为火星坐标的方法
- js判断客户端是iOS还是Android等移动终端的方法
- iOS应用开发中AFNetworking库的常用HTTP操作方法小结
- iOS应用中UISearchDisplayController搜索效果的用法
- iOS App开发中的UISegmentedControl分段组件用法总结
- IOS开发环境windows化攻略
- iOS应用中UITableView左滑自定义选项及批量删除的实现
- iOS中UIAlertView警告框组件的使用教程
- 浅析iOS应用开发中线程间的通信与线程安全问题
- iOS中的UIKeyboard键盘视图使用方法小结
- 检测iOS设备是否越狱的方法
- .net平台推送ios消息的实现方法