iOS安全–实时查看模拟器的日志输出
来源:互联网 发布:香草天空知乎 编辑:程序博客网 时间:2024/06/04 19:40
最近在模拟器上面测试SDK,想看看模拟器断开xcode调试的日志输出,发现Xcode-Window-Devices里面并不能看到。
把日志重定向输出到log文件,便可以看到实时的log日志。
重定向日志输出代码:
1
2
3
4
5
6
7
8
9
10
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
}
#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
2
3
4
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[self redirectConsoleLog];
}
[self redirectConsoleLog];
}
运行Xcode,得到document的目录,然后定位到该目录下面。
1
2
3
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
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
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)
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)
Log打印:
NSLog(@”this is my log”);
fprintf(stderr,”%s\n”,”this is my log”);
本文链接:http://www.blogfshare.com/redirect-console-log.html
iOS安全–实时查看模拟器的日志输出
最近在模拟器上面测试SDK,想看看模拟器断开xcode调试的日志输出,发现Xcode-Window-Devices里面并不能看到。
把日志重定向输出到log文件,便可以看到实时的log日志。
重定向日志输出代码:
1
2
3
4
5
6
7
8
9
10
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
}
#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
2
3
4
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[self redirectConsoleLog];
}
[self redirectConsoleLog];
}
运行Xcode,得到document的目录,然后定位到该目录下面。
1
2
3
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
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
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)
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)
Log打印:
NSLog(@”this is my log”);
fprintf(stderr,”%s\n”,”this is my log”);
本文链接:http://www.blogfshare.com/redirect-console-log.html
0 0
- iOS安全–实时查看模拟器的日志输出
- iOS安全–实时查看模拟器的日志输出
- 一种ios模拟器实时查看日志方法
- IOS Xcode模拟器查看日志
- strace实时查看进程日志输出
- iOS逆向 实时查看手机日志
- Xcode模拟器和真机生成的日志查看(ios必知必会)
- Xcode模拟器和真机生成的日志查看(ios必知必会)
- Xcode模拟器和真机生成的日志查看(ios必知必会)
- 如何实时查看linux下的日志
- 如何实时查看linux下的日志
- 如何实时查看linux下的日志
- 如何实时查看linux下的日志
- 如何实时查看linux下的日志
- 如何实时查看linux下的日志
- 如何实时查看linux下的日志
- 如何实时查看linux下的日志
- 查看linux日志文件的实时情况
- kotlin基础
- js 表格操作
- 下载最新的版本的SVN方法
- 【Python学习笔记】单元测试
- MAVEN项目目录结构
- iOS安全–实时查看模拟器的日志输出
- 易语言 文件捆绑机的原理【转载】
- 【2014.8.17NOIP普及组模拟】数池塘
- iOS获取UUID,并使用keychain存储
- Git command
- Android 获取ROOT权限原理解析
- RxJava学习
- Loadrunner 网页诊断图
- Mysql常用命令(详细)